Google Tag Manager
Install Quotient website tracking through Google Tag Manager
When someone reaches your website from a Quotient email, social post, or campaign, you want to know what they do next. Quotient's JavaScript pixel records the pages they visit while preserving the campaign, email, or social post that brought them to your site as the source.
If Google Tag Manager is already installed on your website, you can use it to add the pixel without changing your site's code.
Before You Start
You need permission to edit and publish your website's Google Tag Manager web container.
Create your API key in
Settings → Developers. Choose a
Public key and give it the Analytics: write permission. Add your site's
domain, such as https://example.com, to its allowed origins. If you will test
on a staging site, add that domain too.
Allowed origins prevent another website from using your key. The key should
begin with pk_. Never put a private sk_ key in Google Tag Manager or any
other browser code.
Create the Quotient Tag
- Open your website's container in Google Tag Manager.
- Go to Tags and click New.
- Name the tag Quotient Website Tracking.
- Click Tag Configuration and choose Custom HTML.
- Paste the following code into the HTML field, replacing
pk_replace_with_your_public_keywith the public key you copied from Quotient:
<script src="https://unpkg.com/@quotientjs/client@0.6.2/dist/quotient.browser.js"></script>
<script>
Quotient.QuotientClient.init({
apiKey: "pk_replace_with_your_public_key",
});
</script>
- Click Triggering and choose Initialization – All Pages.
- Click Save.
The Initialization trigger loads Quotient early on each page. The pixel records the current page when it starts and watches later browser navigation automatically, including navigation in single-page applications. Do not add a separate page-view tag or trigger, or each visit may be counted twice.
Google recommends using Consent Initialization only for tags that set or update consent. The Quotient tag itself should use Initialization – All Pages, unless your consent setup requires a different trigger.
Preview the Tag
Test your changes before you publish them:
- Click Preview in Google Tag Manager.
- Enter your website's URL and click Connect.
- In Tag Assistant, select the page's initialization event.
- Confirm that Quotient Website Tracking appears under Tags Fired.
- Move between a few pages on your site.
The Quotient tag should initialize once when the page loads. Quotient tracks later navigation itself, so the tag does not need to fire again for every history change.
Publish the Container
Once the preview works, return to Google Tag Manager and click Submit. Choose Publish and Create Version, give the version a descriptive name such as "Add Quotient website tracking," and click Publish.
Saving the tag does not change your live website. The tag only starts running for visitors after you publish the container.
Check the Installation
Visit the published site and move between a few pages. To confirm that the pixel is sending data:
- Open your browser's developer tools and select Network.
- Reload the page.
- Search the requests for
analytics/web. - Select the request and confirm that its status is
200.
If the request returns 403, check the key's allowed origins and Analytics:
write permission. If there is no request, make sure the container is
published, use Tag Assistant to confirm that the tag fired, and check that the
key begins with pk_.
If your site uses a Content Security Policy, allow scripts from
https://unpkg.com and connections to https://www.getquotient.ai.
Initialize Quotient only once. If the pixel was already installed directly on your site or through another integration, remove that copy before publishing the Google Tag Manager tag.
Privacy and Consent
The pixel stores device and session identifiers in the visitor's browser. Your privacy notice and consent setup should cover this tracking.
If you require consent before loading analytics, do not use the unrestricted Initialization – All Pages trigger. Configure your consent management tool to push an event when the visitor accepts analytics tracking, then use that event as the Quotient tag's trigger. This ensures the tag can fire immediately after consent is granted, even when the visitor initially declined or had not yet made a choice.
To record your own conversion events after setup, see Custom Events. For the complete API reference, see the JavaScript analytics API.