Skip to content

Instantly share code, notes, and snippets.

<script async src="https://www.googletagmanager.com/gtag/js?id=G-ABCD1EFG2H"></script> // In the case of GA4, this script should be loaded, replacing G-ABCD1EFG2H with your GA4 measurement ID.
<script>
(function(nonVWOScriptsToExecute, VWO_HARD_TIMEOUT) {
window._vwo_evq = window._vwo_evq || [];
var queue = window._vwo_evq;
for (var i = 0; i < queue.length; i++) {
if (queue[i][0] === 'rD') {
window.willRedirectionOccur = true;
break;
@vwo-kb
vwo-kb / JSON
Last active April 15, 2025 07:26
RudderStack
{
"properties": {
"experimentId": "102",
"VariationId": "1",
"CampaignName": "Hero Section - A/B",
"variationName": "Control"
},
"event": "VWO",
"type": "track"
}
<!-- Start VWO Async SmartCode -->
<link rel="preconnect" href="https://dev.visualwebsiteoptimizer.com" />
<script type='text/javascript' id='vwoCode'>
_vis_opt_url = document.location.protocol + '//' + document.location.hostname +
document.location.pathname + "?preview_theme_id=XXXXXXX&" +
document.location.search.substring(1, ) + document.location.hash; //Replace "XXXXXXX" with your Shopify Preview theme ID
window._vwo_code || (function() {
var account_id=XXXXX, //Replace XXXXX with your accountID
_vis_opt_url = window._vis_opt_url || document.URL,
version=2.0,
window.VWO = window.VWO || [];
window.VWO.push(['onVariationApplied', function(data) {
if (!data) {
return;
}
var expId = data[1];
var variationId = data[2];
if (typeof(_vwo_exp[expId].comb_n[variationId]) !== 'undefined' && ['VISUAL_AB', 'VISUAL', 'SPLIT_URL', 'SURVEY'].indexOf(_vwo_exp[expId].type) > -1) {
utag.link({
event_category: "VWO",
// If VWO is not going to redirect the page
if (!window.willRedirectionOccurByVWO) {
//EXECUTE GA CODE HERE
} else {
// VWO is redirecting this page. So, don't execute UA/GA code here.
}
-- Set variables (must be uppercase)
SET VWO_ROLE = 'VWO_ROLE';
SET VWO_USERNAME = 'VWO_USER';
SET VWO_WAREHOUSE = 'VWO_WAREHOUSE';
SET VWO_DATABASE = 'VWO_DATABASE';
SET VWO_SCHEMA = 'VWO_SCHEMA';
-- Set user password
SET VWO_PASSWORD = 'secure_password';
function convertToDefaultCurrency(amount, fromCurrency, precision = 2) {
/**
* Your array of currencies and their conversion rates relative to the default currency
* Example: If USD is your store currency or the one in which you want to track revenue and
* 1 USD = 0.8 GBP then the entry in the array will be "GBP": 0.8
**/
var currencyConversion = {
"USD": 1,// Always keep the default store currency in the array and keep the value as 1
"EUR": 1.1,
"GBP": 0.82,
vwo.addShopifyMiddleware((payload) => {
let newPayload = payload;
if(payload.name == "shopify.productViewed"){
newPayload.name = "newShopifyEventName" ;
}
return newPayload;
});