How to track anchor links using Google Tag Manager and Google Analytics?

Viewed 3835

I have a Single Page App (SPA) which is built on BackboneJS. I've integrated Google Analytics via the instructions here for Google Tag Manager:

http://tech.webinterpret.com/how-to-make-google-analytics-work-in-a-single-page-application-spa/

Unfortunately, this only shows the source of the app, not the different anchor links (or 'pages') when the route is changed.

How can I also store the anchor link as part of the pageview using Google Tag Manager and Google Analytics in a BackboneJS app?

1 Answers

You could push a "virtual pageview" when the user clicks an anchor link. You can find more information on this link http://blog.analytics-toolkit.com/2014/virtual-pageviews-google-analytics-why-how-when/

Extracted from that link:

Virtual Pageview Setup with Google Tag Manager (GTM) Since Google Tag Manger (GTM) is often used to deliver Google Analytics tags, here are instructions on how to set up virtual pageviews in GTM.

First, create a new Google Analaytics tag, or copy an existing one, and set its type to “Pageview”, then check “Enable overriding settings in this tag”. Expand “More Settings” and “Fields to Set”. Finally, add 2 new fields and put “page” and “title” for field names. The values can be fixed or can reference a variable, as usual. Follow the same guidance for the values of “page” and “title” as provided above and below this section. The trigger will vary depending on your implementation. That’s it!

How to set a Virtual Page View from Tag Manager


It's preferable to push Pageviews instead of Events, because Analytics only tracks events once per session, moreover, if you want to build conversion funnels you are going to need to do it with pageviews.

Related