Tracking Single Page Application Events with Google Tag Manager

Tracking specific single page application events on a page with a universal pixel in Google Tag Manager (GTM) involves three steps:

  1. Create a Universal Pixel in Basis.

  2. Call the Universal Tracking Function on the Web Page.

  3. Create the Tag and Trigger for Your Universal Pixel in GTM.

1. Create a Universal Pixel in Basis

Universal pixels can act as conversion pixels and audience pixels on multiple pages at once. This lets you use a single pixel on different pages on your website, and even place that pixel before conversions or audiences are set up. See Universal Pixels for more information.

Before creating a universal pixel, identify the URL and the single page application event that you want to track. In this scenario, you’ll gather audience data from the Available Plans page.

Example website showing URL and single page application event.

2. Call the Universal Tracking Function on the Web Page

We recommend using this method for setting up a universal pixel to fire on non-page-view events because it's most suitable for tracking an event that doesn't cause users to go to a new page. See Universal Pixel Script for more information on placing the pixel script and JavaScript for data objects into web pages.

Separate the loading of the “up.js” script from the calling of the cntrUpTag.track() function. For example, load only the “up.js” script in the HEAD or BODY section of the page, and then call cntrUpTag.track() when users take the desired action.

3. Create the Tag and Trigger for Your Universal Pixel in GTM

After installing your GTM Container on all pages of the site, create the tag. A tag is made up of two components: tag configuration and triggering. Tags are segments of code provided by analytics, marketing, and support vendors to help integrate their products into websites or mobile apps. With GTM, you no longer need to add these tags directly to your projects. You configure and publish tags from within GTM. See Google's About Tags page for more information.

QA – How to Check if the Universal Pixel is Firing in Chrome

After the GTM container has been published, check if the universal pixel is firing on all pages correctly in a live environment.

To check if your universal pixel is firing in Chrome:

  1. In Google Chrome, select Chrome’s Menu icon > More tools > Developer tools (Ctrl+Shift+I) on the newly pixeled page to open the Developer tools panel.

  2. Select the Network tab.

  3. Search for the key value, page=availableplans in this case, then click the specified button to see if the universal pixel fires in real time.

    Chrome developer tools showing pixel fires in real time.