Suppose you want to start a new campaign and segment your subscribers on the basis of the page they browsed. How would you do that? You would be firing our Javascript API which simply adds to the segment of your liking.  How would you configure this dynamically, without changing the code?

This is where Google Tag Manager (GTM) comes handy. Google Tag Manager is a user-friendly solution to managing the tags, or the snippets of JavaScript that send information to third-parties, on your website or mobile app. You use the interface to decide what needs to fire and on what page or what action. GTM then adds the appropriate tracking to your site to make sure it all works, and it is one of the best tools for marketers.

Example – If URL contains turmeric, then add to segment Turmeric like this –

_pe.addSubscriberToSegment(‘segmentName’);

Here is our step by step GTM guide to fire PushEngage tags/API

Example:  If the URL contains Features and is a page which is in a subdirectory below features, we will add the segment Features to the web push subscriber.

  1. Create a New Trigger -> Features URL Trigger in GTM
  2. Configure the Page URL pattern using RegEx, or any other mechanism.custom-firing-on-featured-url
  3. On this Trigger fire a Custom Tag, which has Push Engage code.

Note, please ensure we are firing the correct version of PushEngage JS API.  If you have added PushEngage using Legacy code, then use Legacy API. If you have added Push Engage using the Asynchronous code, then use that API.

https://www.pushengage.com/api/js-async-api/

For Async code, the call to add to segment is  window._peq.push([‘add-to-segment’,’segmentName’]);

See how to add this code in GTM

feature-url-trigger-usong-GTM-for-pushengage

That’s all. Now all you’re your subscribers will be segmented based on their browsing patterns. You can then send a relevant notification based on their geo location, device-browser used during subscription or the date range.