Shopify
One script tag in theme.liquid, and signals built from Liquid objects.
Not an App Store app
This is a theme edit. It does not survive switching themes, and it puts your keys in a theme file that anyone with theme access can read. Publishable keys are designed to be visible in page source, so that is a housekeeping problem rather than a security one.
1. Add the script
Online Store → Themes → Edit code → layout/theme.liquid, just before </head>:
<script src="https://cdn.thepulseapi.com/sdk/v0/pulse.iife.js" async></script>
<script>
window.addEventListener('load', function () {
Pulse.init({
apiKey: 'pk_live_...',
organizationId: 'org_...',
});
});
</script>The script tag exposes the client as the global Pulse. async means it may not have loaded
when inline script runs, which is why init goes inside a load listener rather than being
called immediately.
2. Send signals from the templates
Liquid already knows what the shopper is looking at. Each template sends what it knows.
<script>
window.addEventListener('load', function () {
Pulse.track([
{ type: 'category_view', value: {{ collection.handle | json }} }
]);
});
</script><script>
window.addEventListener('load', function () {
Pulse.track([
{ type: 'product_view', value: {{ product.id | json }} },
{ type: 'category_view', value: {{ product.type | handleize | json }} },
{ type: 'brand_view', value: {{ product.vendor | handleize | json }} }
]);
});
</script>Use the json filter, not quotes
{{ product.vendor | json }} escapes the value properly. Wrapping it in your own quotes breaks
on the first vendor with an apostrophe in the name, and does it only for that vendor, which is
the kind of bug that reaches production.
3. Record outcomes
Shopify fires its own events. Forward the ones that mean something.
<script>
document.addEventListener('cart:item-added', function (event) {
Pulse.event('add_to_cart', { productId: event.detail?.id });
});
</script>The event name varies by theme: Dawn and its descendants publish cart:item-added, older themes
publish their own. Check what your theme dispatches before trusting this one.
What is not covered
Checkout. Shopify does not let a theme script run on checkout pages outside Plus, so purchase outcomes have to come from your server via a webhook, not from the browser. See Backend for the call to make when the webhook arrives.

