Skip to content

Instantly share code, notes, and snippets.

@vwo-kb
vwo-kb / JSON
Last active January 3, 2025 11:32
RudderStack
{
"properties": {
"experimentId": "102",
"VariationId": "1",
"CampaignName": "Hero Section - A/B",
"variationName": "Control"
},
"event": "VWO",
"type": "track"
}
// 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.
}
<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;
-- 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;
});
vwo.addShopifyMiddleware((payload) => {
let newPayload = payload;
// customCode logic here
return newPayload;
});
payload = {
name: “shopify eventName” // mandatory field
props: {
// properties to be shown in VWO’s Events
}
}