Hi.. I've setup A/b testing for my shopify product...
# ask-questions
a
Hi.. I've setup A/b testing for my shopify product page. but it says no data. Can anyone please help if i've done the setup correctly
f
Can you share the page?
Also, are you using GTM?
not sure about GTM
f
Looks to be working
I see there is one experiment
a
but on growthbook side, i see no data
f
Screenshot 2025-05-08 at 12.27.38 AM.png
how long has it been?
a
i set this up yesterday
f
Google Analytics?
a
no.. growthbook variation
do i need to setup google analytics too on website?
f
so GrowthBook is a warehouse native platform, we don't ingest tracking data directly (atm, coming soon)
a
i mean how can i track if 505% traffic is being splitted for product page
?
<!-- Google Tag Manager --> <script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src= 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); })(window,document,'script','dataLayer','GTM-MF4WS6R');</script> <!-- End Google Tag Manager -->
f
okay
a
google tag manager is there
f
a
can you once check if my growthbook settings are correct
i can share logins with you
f
the settings look okay from the outputs of GrowthBook
a
okay so now i need to do the setup on GTM side as mentioned in the doc above
right?
f
do you have a GTM account currently?
a
i'll have to check with client
f
yes, most likely you do have to follow our steps (I believe google changed the steps around a little bit)
did you set a trackingCallback or are you using the default one?
a
i added the code in my shopify side
<script src="{{ 'growthbook.min.js' | asset_url }}"></script> <script> window.growthbook = new growthbook.GrowthBook({ apiHost: "https://cdn.growthbook.io", clientKey: "secret_user_D21UH1AD2ndDuU5djcbN6nYkgYOa4xymyGFqJXdPY", // replace this enableDevMode: true, trackingCallback: function (experiment, result) { console.log("Viewed Experiment", experiment.key, "Result:", result); } }); growthbook.loadFeatures(); growthbook.setAttributes({ id: Math.random().toString(36).substring(7), page_type: "product" }); const result = growthbook.run({ key: "product_page_variant", variations: ["control", "variant-a"] }); if (result.value === "variant-a") { document.getElementById("control-layout").style.display = "none"; document.getElementById("variant-a-layout").style.display = "block"; } </script>
f
pj
oh
a
is it wrong?
f
well, the trackingCallback is wrong
the other parts look oaky
a
can you help me fix that
f
ya
There are a few problems
trackingCallback: function (experiment, result) { //console.log("Viewed Experiment", experiment.key, "Result:", result); window.dataLayer.push({ event: "experiment_viewed", experiment_id: experiment.key, variation_id: result.key, }); }
you'll want a tracking callback like that
two, your ID is not persistent
you will need to store the ID or use a shopify one
3: const result = growthbook.run({ key: "product_page_variant", variations: ["control", "variant-a"] }); - this is an inline experiment, are you sure you want to load the experiment this way?
a
what is the difference?
f
you can do it inline if you want
but I also see an experiment set in the GrowthBook ui
a
Let me give you a brief
i have a shopify product page and i created another variation with the figma design. now i want to split traffic on both variations using growthbook
so i setup this
now based on my requirement, please correct my code and let me know what i need to do further'
Hello @fresh-football-47124 Are we still connected?
Hello @fresh-football-47124 Can you please let me know the updated code i've to write there in shopify?
s
Were you able to figure this out?
a
Hello @strong-mouse-55694
No
Will you help me on this?
s
I can try. It looks like you're using a combination of script tags and GTM. Is that right? Can you share also where you got to and what's the blocker at the moment?
a
Hello @strong-mouse-55694 I setup the experiment in growthbook and use the required code in shopify. GTM is already implemented. Graham confirmed me that setup is correct but i see no data on growthbook side. Is there anything i need to do further? how can i track users for a/b testing?
Its been long i am seeking help on this. please ping me when you are available. we can sort this out togetherr
s
Hi there. I checked your page. I can that GrowthBook is loaded and there is an active experiment. However, I don't see the experiment exposure event in GTM, though. 1. Have you followed all the steps to configure GrowthBook with GTM? There's several things you need to do in order for this work like connecting GTM to GA4 and then GA4 to BigQuery. 2. How are you running the experiment on the page?
a
Hi @strong-mouse-55694 Thanks for checking
I just created a new variation of my page in shopify and then created experiment in growthbook and used the growthbook code in my shopify theme file