jolly-spring-26283
01/26/2024, 7:49 PM<http://mywebsite.com/?preview_theme_id=127602196534|mywebsite.com/?preview_theme_id=127602196534>
Maybe we can achieve this using feature flag?
Like when we get true
value of feature we redirect to theme B else we keep our theme A.
Also we want to measure some matrices in both themes (we can do that using GA4 bigquery as datasource)
Is this approach a better way...? please guide.jolly-spring-26283
01/26/2024, 7:51 PMfresh-football-47124
jolly-spring-26283
01/29/2024, 4:07 PMfresh-football-47124
jolly-spring-26283
01/29/2024, 4:08 PM<script
id="growthbook-sdk"
src="<https://cdn.jsdelivr.net/npm/@growthbook/growthbook/dist/bundles/index.min.js>"
></script>
<script>
(function () {
function getUUID() {
let $ = 'gbuuid',
e = () =>
window.crypto.randomUUID
? window.crypto.randomUUID()
: '10000000-1000-4000-8000-100000000000'.replace(/[018]/g, ($) =>
($ ^ (crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> ($ / 4)))).toString(16)
),
t = ($) => {
let e = `; ${document.cookie}`.split(`; ${$}=`);
if (2 === e.length) return e.pop().split(';').shift();
},
r = ($, e) => {
var t = new Date();
t.setTime(t.getTime() + 3456e7), (document.cookie = $ + '=' + e + ';path=/;expires=' + t.toGMTString());
};
if (t($)) return t($);
let i = e();
return r($, i), i;
}
function getCustomerId() {
let c = document.querySelector('#customerIdForGB')?.value;
return c;
}
// Wait for the SDK to load before starting GrowthBook
if (window.growthbook) {
startGrowthbook();
} else {
document.querySelector('#growthbook-sdk').addEventListener('load', startGrowthbook);
}
function startGrowthbook() {
if (!window.growthbook) return;
let gbUserId = getCustomerId() || getUUID();
let gb = new growthbook.GrowthBook({
apiHost: '<https://cdn.growthbook.io>',
clientKey: 'sdk-CLIENTID',
attributes: {
id: gbUserId,
},
experiments: [
{
key: 'barton_ga4',
variations: [true, false],
},
],
trackingCallback: function (experiment, result) {
console.log('result', result);
console.log('experiment', experiment);
console.log(`%c Now we are on PREVIEW THEME `, 'color:white;background:orange;font-size:20px;');
gtag('event', 'experiment_viewed', {
event_category: 'experiment',
experiment_id: experiment.key,
variation_id: result.variationId,
gb_user_id: gbUserId,
});
},
});
window.gb = gb;
// TODO: Instrument DOM with AB test logic
gb.loadFeatures().then(function () {
// if you want to do anything after GB loads
});
}
})();
</script>
fresh-football-47124
fresh-football-47124
fresh-football-47124
function getCustomerId() {
let c = document.querySelector('#customerIdForGB')?.value;
return c;
}
fresh-football-47124
jolly-spring-26283
01/29/2024, 4:10 PMjolly-spring-26283
01/29/2024, 4:11 PMfunction getCustomerId() {
let c = document.querySelector('#customerIdForGB')?.value;
return c;
}
this is for the logged in user,
like if the user is logged in we can use the customer id from Shopify instead of creating our own id.fresh-football-47124
fresh-football-47124
fresh-football-47124
jolly-spring-26283
01/29/2024, 4:15 PM*Sample Ratio Mismatch (SRM) detected. P-value below 0.001*.
Multiple Exposures Warning
fresh-football-47124
fresh-football-47124
fresh-football-47124
jolly-spring-26283
01/29/2024, 4:17 PMjolly-spring-26283
01/29/2024, 4:19 PMfresh-football-47124
fresh-football-47124
fresh-football-47124
jolly-spring-26283
01/29/2024, 4:22 PM