OptimeleonOptimeleon
Request Access
Setup

Integrating the Script (for Shopify)

Add the base script to your Shopify theme, create a custom pixel for checkout events, and unblock Optimeleon via CSP.

Now that you understand how our scripts work and their importance for both optimization and GDPR compliance, let's integrate them into your Shopify website. Adding the script is as simple as copying a few lines and pasting them on your page!

Important
Creating campaigns for Shopify checkout pages is not allowed from Shopify's end due to security concerns.
01

Add the base script to the <head>

The base script is responsible for selecting variants and tracking user behavior in a cookieless manner. It ensures instant page loading without flickering and complies with GDPR by not using cookies – only memory.

  • Find the <head> section of your Shopify theme code.
  • On the Script page, locate the “Script Version” dropdown on the top right and choose Shopify.
  • Copy the code and insert the script tag within the <head> section of your Shopify theme.
Tip
We recommend turning Manual consent mode off and keeping Reduce Flicker on. (See editing Shopify theme code.)
02

Create a Shopify pixel

You'll need to create a custom pixel on your Shopify website if you plan to track conversion events on the checkout page.

  • Jump to Step 3 on the Script page (with Shopify selected as the script version).
  • Copy the code provided there and paste it into your Shopify pixel.
Note
That's it – once you create a campaign, your pages will automatically come to life!
03

Activate first-party cookies after consent (optional)

Note
Follow this step only if you kept manual consent toggled on. Optimeleon will not use cookies in this case. Please read the Cookies section under How it works? to understand the trade-offs.

When a user gives consent, execute the following function to activate first-party cookies:

consent function
setOptiCookieConsent('yes');
04

Validate your script integration

Note
The Validate Script function is currently unavailable for Shopify, as Shopify hides the scripts.

Tracking is one of the main functions of Optimeleon's script. You can check whether Optimeleon is able to track events by following the Conversion Events guide – this is also a good indicator that other parts of the script are functioning.

Next steps

With the scripts successfully integrated, you're now ready to:

  • Create campaigns – set up campaigns to test different variants of your pages, and define hypotheses and target elements for optimization.
  • Monitor performance – use the dashboard to track variant performance and analyze user interactions and conversion metrics.
  • Leverage AI optimization – allow our AI models to learn from the collected data and benefit from continuous optimization without manual intervention.
Important
Please ensure Optimeleon is unblocked on your website, mainly via a CSP meta tag. It should look something like this:
Content-Security-Policy meta tag
<meta http-equiv="Content-Security-Policy"
      content="default-src 'self'; script-src 'self' *.optimeleon.com">

Also, a few tools like Cookiebot need to be instructed to allow Optimeleon scripts to run on your website.

Congratulations!
You've successfully integrated the Optimeleon scripts into your website. You're now on your way to unlocking the full potential of continuous, AI-driven optimization.