Deploy Second Tag and Trigger for SPA Websites

  • Updated

If your website is a single-page application (SPA), you must configure an additional tag and trigger in Google Tag Manager (GTM) to fire the Demandbase API when the URL changes without a full page reload.

See Google’s article Components of Google Tag Manager.

For instructions on deploying the initial Demandbase tag, see Deploy Demandbase One Tag via Google Tag Manager (GTM).


Create a Tag for SPA URL Changes

  1. In GTM, create a new tag.
  2. For Tag Type, select Custom HTML.

  3. In the HTML box, enter the following code:
    <script type="text/javascript">
    //ensures Demandbase API is fired on each URL change  
    Demandbase.IpApi.get()
    </script>
  4. Under Advanced Settings > Tag Firing Option, select Once per event.
  5. Click Save.
    GTM Tag.png

Create a Trigger for SPA URL Changes

  1. In GTM, create a new trigger.
  2. For Trigger Type, select History Change.
  3. Under This trigger fires on, select All History Changes.
  4. Click Save.
  5. Assign the History Change trigger to the Custom HTML tag you created.
  6. Save your changes and publish the GTM container.
    Trigger+Example+%282%29.png