Integration Guides

Google Tag Manager

Deploy the Otus tracking script through Google Tag Manager without touching your site's code.

If you already use Google Tag Manager (GTM), you can deploy Otus through it without editing your site's HTML.

A dedicated GTM template is on the way. In the meantime, the Custom HTML tag method below works today.

Add Otus as a Custom HTML tag

  1. Open your Google Tag Manager container.
  2. Go to Tags → New → Tag Configuration → Custom HTML.
  3. Paste your Otus snippet into the HTML field:
    <script async src="https://cdn.otusanalytics.com/otusanalytics/otus.js"></script>
    <script>
      window.otus=window.otus||function(){(otus.q=otus.q||[]).push(arguments)},otus.init=otus.init||function(i){otus.o=i||{}};
      otus.init({ siteId: 123, endpoint: "https://ingest.otusanalytics.com/e" })
    </script>
    
  4. Under Triggering, choose All Pages (the Initialization or All Pages trigger) so the script loads on every page.
  5. Save, then Submit / Publish your container.

A note on accuracy

Because GTM itself is a script that loads after the page, deploying Otus through a tag manager can slightly undercount visitors who leave very quickly or who block tag managers. For the most accurate numbers, the direct script tag in your <head> is preferred.

Tracking custom events from GTM

You can fire Otus custom events from GTM tags. Add a Custom HTML tag with the appropriate trigger (for example a button-click trigger):

<script>
  otus('track', 'signup_click', { plan: 'growth' });
</script>

Custom event names must be lowercase letters, numbers and underscores (max 64 characters). See the Tracking API for details.

To connect events across sessions or devices, pass a linking ID as the fourth argument, for example a cart ID from a data layer variable: otus('track', 'begin_checkout', { value: 89 }, {{DLV - cart ID}});. Never use a user ID or email address as linking ID.

Identifying logged-in users from GTM

On sites in full tracking mode, a Custom HTML tag on a login or page-view trigger can pass your internal user ID (never an email address), and another on logout can reset it:

<script>
  otus('identify', {{DLV - user ID}});
</script>
<script>
  otus('reset');
</script>

See identify for how this works with consent.

Otus never assumes consent: until you tell it otherwise, visits are counted anonymously and nothing is forwarded to ad platforms. Most consent management platforms (Cookiebot, OneTrust, Usercentrics, …) push a consent event to the data layer when the visitor makes a choice. Add a Custom HTML tag that fires on that event and forwards the choice. Most CMPs also push it on page load when a returning visitor already has a stored choice. Don't fire this tag before the visitor has answered, or an unanswered banner would be recorded as a denial:

<script>
  otus('setConsent', {
    analytics: {{CMP - statistics consent}} === true,
    marketing: {{CMP - marketing consent}} === true
  });
</script>

Replace the two variables with the ones your CMP provides. The snippet's queue stub makes the call safe even if it runs before the tracker has loaded. See consent for what each category controls, and consentWait if your CMP reports stored choices slightly after page load.

Next step

After publishing, verify your installation.