ThriveCart
Add OnyxMetric analytics to your ThriveCart checkout pages
ThriveCart lets you add custom scripts to each checkout page, and its success page is where the purchase event goes. ThriveCart strips data-* attributes from script tags, so the site ID must travel in the script URL, as it does in the standard snippet.
Copy your tracking snippet
In OnyxMetric, open your site's Site Settings and copy the tracking script. It looks like this:
<script src="https://app.onyxmetric.com/api/script.js?siteId=YOUR_SITE_ID" async></script>YOUR_SITE_ID is the numeric ID of your site.
Add the snippet to ThriveCart
- In your ThriveCart dashboard, open the checkout page you want to track.
- Open Settings > Tracking, the custom scripts section.
- Paste the snippet into the header scripts field and save.
Repeat for each checkout page. If checkout runs on a subdomain such as sales.yourdomain.com and your main site uses the same site ID, both are tracked as one site, so funnels can follow a visitor from your site through to the purchase.
Check that it works
Load your live site and click through a few pages. Pageviews show up in the OnyxMetric dashboard within seconds.
If nothing arrives:
- View the page source and search for
script.js?siteId=to confirm the tag is present. - In the browser's Network tab, check that
script.jsreturns200and that requests go to/api/track. - Turn off ad blockers, or proxy the script through your own domain.
- Read script troubleshooting for other causes.
Track purchases
ThriveCart also interferes with inline events, so this success-page script loads the tracker itself if it is missing, waits for it, and uses sessionStorage to send the event once per browser session even if the visitor refreshes.
Add it to the checkout's success page and fill in the values at the top:
<script>
(function () {
var EVENT_NAME = "purchase";
var PAYLOAD = { content_name: "Your Product Name", value: 97.0, currency: "USD" };
var SITE_ID = "YOUR_SITE_ID";
var SCRIPT_SRC = "https://app.onyxmetric.com/api/script.js?siteId=" + SITE_ID;
// Send once per session, even on refresh or back navigation
var SENT_KEY = "onyx_" + EVENT_NAME + "_sent_v1";
try {
if (sessionStorage.getItem(SENT_KEY) === "1") return;
sessionStorage.setItem(SENT_KEY, "1");
} catch (e) {}
function isReady() {
return window.onyx && typeof window.onyx.event === "function";
}
function send() {
window.onyx.event(EVENT_NAME, PAYLOAD);
}
function waitThenSend(timeoutMs) {
var start = Date.now();
(function check() {
if (isReady()) return send();
if (Date.now() - start < timeoutMs) setTimeout(check, 150);
})();
}
if (isReady()) return send();
if (!document.querySelector('script[src="' + SCRIPT_SRC + '"]')) {
var s = document.createElement("script");
s.src = SCRIPT_SRC;
s.async = true;
document.head.appendChild(s);
}
waitThenSend(8000);
})();
</script>EVENT_NAME: the event name, for examplepurchaseorcheckout_complete.PAYLOAD:content_name(product name),value(amount), andcurrency(USD,GBP,EUR, and so on).SITE_ID: your OnyxMetric site ID.
Selling several products? The payload is fixed per page, so use a separate success page per product, or fill PAYLOAD from ThriveCart's dynamic variables where available.
Troubleshooting
- Script attributes are stripped: ThriveCart removes
data-*attributes, so script attributes such asdata-skip-patternsdo not work here. Keep the site ID in the URL. - Duplicate purchase events: the script is guarded by
sessionStorage. If you still see duplicates, make sure the event script is on the success page only once, and clear session storage before testing again. - Script blocked: if
script.jsnever loads, try the footer scripts field instead of the header, or ask ThriveCart support whether custom scripts are enabled on your account.
Next steps
- Track custom events such as signups, purchases, and clicks.
- Identify users to tie sessions to accounts.
- Proxy the script through your own domain to get past ad blockers.
- Script attributes let you skip or mask URLs and tag events.