Split testing with Google Analytics

Highlighted
New Member
1 0 0

Hey guys,

I'm trying to set up an experiment with Google Analytics (a split test). I created two versions of a landing page, and for the experiment to work, I'm supposed to paste a code snippet into the head section of the original page.

The question is: how do I do that in a way that it only applies to the head section of that single page?

Any help would be much appreciated.

Cheers,

Greg

0 Likes
Highlighted
Shopify Expert
727 57 162

You can use liquid to conditionally load it only on the page.

 

Here are a couple examples:

{% if product.handle == "the product's handle" %}
  script code here
{% endif %}

{% if page.handle == "a page's handle" %}
  script code here
{% endif %}

You can learn more about liquid in their docs: https://shopify.dev/docs/themes/liquid/reference/objects/page

Founder of Speed Boostr (Shopify optimization and dev agency).
Creator of Theme Scientist (A/B testing app).
Creator of Order Automator (app that auto tags + fulfills orders, send emails).
Creator of Tip Jar (add a tip button to your store).
Creator of Shopify Analyzer (free performance analysis tool).
My team also builds custom apps and automated solutions.
Enjoy the adventure!
0 Likes