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!
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.
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.
Activate first-party cookies after consent (optional)
When a user gives consent, execute the following function to activate first-party cookies:
setOptiCookieConsent('yes');Validate your script integration
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.
<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.
