Shopify Conversion Tracking
Watch the video tutorial:
To dynamically insert the total cart value into your ad conversion tracking script, you can use the following Liquid code in Shopify’s customer events. The script captures the total price of the cart on the checkout completed event and sends it to your conversion tracking.
<script>
const script = document.createElement('script');
script.setAttribute('src', 'https://a.ads.rmbl.ws/ratag?id=AV-XXXX'); // Replace XXXX with your actual tracking ID
script.setAttribute('async', '');
document.head.appendChild(script);
window._ratagData = window._ratagData || [];
function ratag() {
_ratagData.push(arguments);
}
// Listen for the checkout completion event and send conversion data
analytics.subscribe("checkout_completed", (event) => {
ratag('conversion', {
to: XXXX, // Replace XXXX with your actual tracking ID
value: event.data.checkout.totalPrice.amount // Dynamically pulls total order value from the event
});
});
</script>
Instructions for placement
![Shopify 2](/docs/assets/images/shopify-2-cd71f1608279a79fd7b3c6080a36c44b.png)
- Go to Shopify Admin > Settings > Customer Events.
- Locate the relevant customer event handler, specifically for
checkout_completed
or another event triggered upon checkout completion. - Paste the Liquid code snippet provided above into the customer event handler.
![Shopify 1](/docs/assets/images/shopify-1-5f2df2a118d992da4fc203b9a61a3a95.jpeg)
- Replace
XXXX
in both instances with your actual tracking ID or value.
Test the implementation
- Complete a test purchase to ensure that the conversion value is captured and passed correctly.
- Check your ad tracking platform to verify the data is being sent.
- Review your browser’s console to ensure the script runs without errors.
The following Liquid script will dynamically track the order total on checkout completion and integrate the conversion tracking into Shopify’s customer event system. Be sure to replace the placeholders and thoroughly test your setup.
const script = document.createElement('script');
script.setAttribute('src', 'https://a.ads.rmbl.ws/ratag?id=AV-XXXX');
script.setAttribute('async', '');
document.head.appendChild(script);
window._ratagData = window._ratagData || [];
function ratag() {_ratagData.push(arguments);}
analytics.subscribe("checkout_completed", (event) => {
ratag('conversion', {
to: XXXX,
value: event.data.checkout.totalPrice.amount,
}
);
});