How to call tag manager code in infinite scroll website pages?

Infinite scrolling pages, means at the end of a page next page will be loaded. This is latest trends in websites now. Especially in news website.

Here we added instruction to track these infinite page scroll analytics using google analytics.

Here we creating an event to get google analytics details while page scrolls:

Event name :Scrollview

Variables :pageurl, pagetitle

dataLayer.push({
‘event’:’Scrollview’,
‘pageurl’:titleurl,
‘pagetitle’:title
});

Using this variable and event we need to configure an event in google tag manager console.

Call the above javascript code in the js file (or ajax calling of new page) that used to call next page scroll.

Then in the google tag manager console:

1. In the “Variables” section in google tag manager you need to define a “User defined Variable” the varibales used in Data Layer Variable: eg: pageurl

2. In the Trigger section you need to configure a  “Custom Event” Scrollview
Also specify what you need to trigger in this event. In Tag configuration insert the Tags, Analytics code etc.

 

3. Then create Tags, Here we need to insert the tag and trigger(that we created in the “triggers” section) used in it.

Publish the workspace and copy and paste the tag manager code in your website.

Using this method you can track the infinite page scrolling analytics in Google analytics.