Install Median's Google Tag Manager Template

Before you get started you need:

  1. A Median app
    1. Create one here if needed
  2. A GTM container ID. To create one:
    1. Create a Google Tag Manager Account and Web Container
      1. Make sure you select Web for the container platform
    2. Copy your container ID

Upload custom JavaScript snippet in the App Studio

  1. On line 1 of the snippet below, replace ENTER-GTM-ID-HERE with your GTM container ID and copy the snippet to your clipboard
var gtmId = 'ENTER-GTM-ID-HERE';
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({ 'gtm.start': new Date().getTime(), event: 'gtm.js' });

var checkReady = setInterval(function () {
  if (document.body) {
    clearInterval(checkReady);
    var f = document.getElementsByTagName('script')[0];
    var j = document.createElement('script');
    j.async = true;
    j.src = 'https://www.googletagmanager.com/gtm.js?id=' + gtmId;
    f.parentNode.insertBefore(j, f);
  }
}, 50);
  1. In the App Studio:
    1. Head over to the Web Overrides page
    2. In the Custom JavaScript section (iOS and Android), paste the snippet from your clipboard. Make sure your GTM container ID is on line 1.
    3. Click Save
    4. Head over to the Build & Deploy page and rebuild your app

App Studio- Paste Custom JavaScript Snippet


Import Median's Tag template in GTM

  1. Download the template's .tpl file from this GitHub repository

  2. In your Google Tag Manager Console:
    a. Head over to Templates
    b. Click New in the Tag Templates section


c. Click the three-dot menu icon in the top right corner of the screen
d. Click Import and upload the .tpl file
e. (Optional) Add a bridge version and userAgentValue in the template's fields. See the configuration fields documented earlier on this page for more information.

  1. Create a new tag from the template and set the trigger to fire on All Pages. This tag injects the Median JavaScript Bridge into your app so that other tags can use it.
  2. Publish your GTM container

Build your own tags

You can create additional tags and triggers to call Bridge commands. For example, a tag can check median.auth.status to determine if a user's device supports Face ID or Touch ID. If it's supported, you can trigger biometric login prompts directly from GTM, without writing code into your website.