Introduction
It is entirely possible for you to integrate your own front-end tracking plugin into your e-commerce solution. The first block of code should be added to the ‘Order Success’ page, while the second block should be deployed on pages such as ‘Product List’, ‘Product Detail’, and so forth. It is of paramount importance to note that the ensuing code block is not a ready-to-use solution. You are required to modify the variables on the right-hand side as per your specific requirements. The js snippet must run only at thank you page(order confirmation page) after creating an order:
// THIS CODE BLOCK GOES FOR ORDER SUCCESS PAGE
<script src="https://partner-cdn.shoparize.com/js/shoparize.js" defer="defer"></script>
<script>
window.dataLayerShoparize = window.dataLayerShoparize || [];
dataLayerShoparize.push({
event: "purchase",
ecommerce: {
transaction_id: "{{ order.order_number }}", // ORDER NUMBER STRING
value: {{ total_price | times: 0.01 }}, // TOTAL PRICE FLOAT
tax: {{ tax_price | times: 0.01 }}, // TAX FLOAT
shipping: {{ shipping_price | times: 0.01 }}, // SHIPPING FLOAT
currency: "{{ order.currency }}", // CURRENCY STRING
items: [ // ARRAY OF ITEMS BOUGTH
{
item_id: "{{ line_item.product_id }}", // ITEM ID STRING
item_name: "{{ line_item.title | remove: "'" | remove: '"' }}", // ITEM NAME WITHOUT ANY SINGLE OR DOUBLE QUOTE ADDED STRING
currency: "{{ order.currency }}", // CURRENCY STRING
price: {{ line_item.final_price | times: 0.01 }}, // PRICE FLOAT
quantity: {{ line_item.quantity }} // QUANTITY NUMBER
}
]
}
});
</script>
<script>
window.addEventListener('load', function () {
SHOPARIZE_API().conv(YOUR_SHOPARIZE_PARTNER_SHOPID);
});
</script>
Do not forgot set up your shop id, as it was above:
SHOPARIZE_API().conv(YOUR_SHOPARIZE_PARTNER_SHOPID);
For example if your shop ID is 1234 it must look like this:
SHOPARIZE_API().conv(1234);
The js snippet must run at all pages of shop as home, category, product(exclude thank you page):
// THIS CODE BLOCK IS FOR PRODUCT PAGES, HOME PAGE ETC.
<script src="https://partner-cdn.shoparize.com/js/shoparize.js" defer="defer"></script>
<script>
window.addEventListener('load', function () {
SHOPARIZE_API().init(YOUR_SHOPARIZE_PARTNER_SHOPID);
});
</script>
Do not forgot set up your shop id, as it was above:
SHOPARIZE_API().init(YOUR_SHOPARIZE_PARTNER_SHOPID);
For example if your shop ID is 1234 it must look like this:
SHOPARIZE_API().init(1234);
The sample request should be similar to something like this:
{
"shopId": "11111",
"dataLayer": {
"ecommerce": {
"transaction_id": "1006",
"value": 0,
"tax": 0,
"shipping": 0,
"currency": "EUR",
"items": [
{
"item_id": "6967987077320",
"item_name": "Nature Cure CBD-Olie 30%/ 30 ml - Nature Cure CBD-Olie 30%/ 30 ml",
"currency": "EUR",
"price": 0,
"quantity": 1
}
]
}
} ,
"_partner_utm_source": "Shoparize",
"_partner_utm_medium": "Shoparize Google Ads",
"_partner_utm_campaign": "EAIaIQobChMI0q_2sM_1-AIVlKnVCh1KPwubEAQYBSABEgJ4Z_D_BwE_____EAIaIQobChMI0q_2sM_1-AIVlKnVCh1KPwubEAQYBSABEgJ4Z_D_BwE_____CjkKCQjwt7SWBhD-ARIoADl0M-UACUEUCM9EiMkioEB5EF--gmZEEXcTh7VLGn4f-z1ZPD",
"_partner_utm_term": "",
"_partner_msclkid": "",
"_partner_gclid": "EAIaIQobChMI0q_2sMQYBSABEgJ4Z_D_BwE",
"_partner_wbraid": "",
"_partner_gbraid": "",
"_partner_click_time": "1657901335434"
}
After that create a test order using a link which Shoparize support team should give you.