Example: Manually Track Pageviews with Sailthru JS and Google Tag Manager
1. Add Sailthru.track Function as a Tag
- In Google Tag Manager, click New Tag, then change the tag’s name from “Untitled Tag” to “Sailthru.track”.
- Copy the code sample below and paste it into the HTML box. We are manually logging a pageview to the URL http://example.com/test.
- Scroll down below the HTML field and click within the Triggering box to add a new trigger, so that Google Tag Manager knows when to fire the tag.
2. Trigger the Tag on Pageview
- After you click in the Triggering box, at the top-right, click to add a new trigger.
- If you’re using a single-page, infinite scroll site you can create a trigger that fires on all pages. Select Add Trigger and select All Pages.
- If you only want this to fire on a certain page, for example a page located at /products you can configure the trigger and Sailthru Track call to only fire on those pages.
- You can optionally give your new trigger a name in the top-left corner.
- Click Save.