Last active
August 24, 2025 13:28
-
-
Save zionskynet/b08525e7b295288d4f5365f6f185beec to your computer and use it in GitHub Desktop.
Voluum and Shopify events tracking integration code. It's based on native Shopify Customer Events, and it really works without any issues.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // https://help.shopify.com/en/manual/promoting-marketing/pixels/custom-pixels/code | |
| // https://shopify.dev/docs/api/web-pixels-api/standard-events | |
| function getPostbackURL() { | |
| try { | |
| const utmMedium = localStorage.getItem('utmMedium'); | |
| const xoClickId = localStorage.getItem('xoClickId'); | |
| if (utmMedium === 'xo' && xoClickId) { | |
| return 'https://your-voluum.domain/postback?cid='+xoClickId; | |
| } | |
| } catch(e) { | |
| console.log(e); | |
| } | |
| } | |
| analytics.subscribe('page_viewed', async () => { | |
| try { | |
| const url = new URL(window.document.location.href), | |
| utmMedium = url.searchParams.get('utm_medium'), | |
| xoClickId = url.searchParams.get('utm_term'); | |
| if (utmMedium === 'xo' && xoClickId) { | |
| localStorage.setItem('utmMedium', utmMedium); | |
| localStorage.setItem('xoClickId', xoClickId); | |
| } | |
| } catch(e) { | |
| console.log(e); | |
| } | |
| }); | |
| analytics.subscribe("product_added_to_cart", async () => { | |
| if (getPostbackURL()) { | |
| const timeStamp = Math.round(Date.now() / 10000); | |
| navigator.sendBeacon(getPostbackURL()+'&et=add_to_cart&txid='+timeStamp); | |
| } | |
| }); | |
| analytics.subscribe("checkout_started", async () => { | |
| if (getPostbackURL()) { | |
| navigator.sendBeacon(getPostbackURL()+'&et=begin_checkout'); | |
| } | |
| }); | |
| analytics.subscribe("checkout_completed", async (event) => { | |
| if (getPostbackURL()) { | |
| const checkout = event.data.checkout, | |
| totalPrice = checkout.totalPrice.amount, | |
| priceCurrency = checkout.totalPrice.currencyCode, | |
| orderId = checkout.order.id; | |
| navigator.sendBeacon(getPostbackURL()+'&et=purchase&payout='+totalPrice+'¤cy='+priceCurrency+'&txid='+orderId); | |
| } | |
| }); |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Read full article about Voluum and Shopify Events Tracking Integration before using this code.
Watch short video How to add tracking code to your store and setup "Customer events pixel" options.