https://www.growthbook.io/ logo
#ask-questions
Title
# ask-questions
s

strong-controller-79207

02/13/2024, 2:31 PM
Hello everyone we are running a redirection test on a shopify store where traffic is split between 2 different themes 85% goes to control and 15% goes to variant here is the code
Copy code
<script
        id="growthbook-sdk"
        src="<https://cdn.jsdelivr.net/npm/@growthbook/growthbook/dist/bundles/index.min.js>"
        defer
      ></script>
      <script>
        (function () {
          if (window.growthbook) {
            startGrowthbook();
          } else {
            document.querySelector('#growthbook-sdk').addEventListener('load', startGrowthbook);
          }

          function startGrowthbook() {
            if (!window.growthbook) return;
            gtag('get', 'G-xxxxxxxx', 'client_id', function (cid) {
              console.log('ga4 id', cid);
              var gb = new growthbook.GrowthBook({
                apiHost: '<https://cdn.growthbook.io>',
                clientKey: 'sdk-xxxxxxxx',
                attributes: {
                  id: cid,
                },
                trackingCallback: function (experiment, result) {
                  console.log('Viewed Experiment', {
                    experiment: experiment,
                    variation: result,
                  });
                  gtag('event', 'experiment_viewed', {
                    event_category: 'experiment',
                    experiment_id: experiment.key,
                    variation_id: result.variationId,
                    userId: cid,
                    send_to: "xxxxxxx"
                  });
                },
              });
              gb.loadFeatures().then(function (x) {
                console.log('faetures loaded', x);
                if (gb.isOn('barton-redirect-v2')) {
                  console.log('Feature enabled redirecting!');
                  var url = new URL(window.location.href);
                  url.searchParams.append('preview_theme_id', '127602229302');
                  window.location.href = url.href;
                } else {
                  console.log('Feature NOT enabled!');
                }
              });
            });
          }
        })();
      </script>
Now the above code is added to both themes the control and the variant except for the redirection part is not added to the variant the problem is the tracking callback is not called on the 15% theme after redirection any clue? thanks in advance
10 Views