Reputation: 8116
I discovered a strange anomaly with GTM event Triggers.
I am capturing event clicks on PDF documents on my web pages and triggering an event record to my Google Analytics. The trigger is shown in the attached screen shot.
(1) when you click a PDF document on the web page (link does not contain a target="_blank" attribute in the html markup), the PDF opens in the current tab and a GA event is recorded -- "success".
(2) when you right-click a PDF document on the web page (link does not contain a target="_blank" attribute in the html markup), and open the link in a new tab or a new window, the PDF opens and a GA event is NOT recorded -- "NO success".
How can I adjust my GTM trigger to successfully capture and record event clicks opened in new tabs and new windows?
Upvotes: 1
Views: 6544
Reputation: 3981
Because right-clicking and opening in a new tab is not a "click" in the eyes of JavaScript. It is however an event that can be tracked. It will require the use of jQuery and a GTM Variable that is Custom JavaScript.
This post has decent instructions on tracking it.
How to Track "Open New Tab" traffic in Google Analytics
Upvotes: 2
Reputation: 884
I've run into this before, and never found a solution; I think it's just the nature of the way GTM tracks people.
Every click on the web page triggers the click listener, which quickly identifies the DOM element you were clicking on, and sends a small packet of data to GTM.
However, right clicking is not the same thing, and doesn't trigger this behavior. The menu that then appears is not part of the web page, so a click on there won't be noticed by GTM.
I can think of two ways around this; the first would be to write your own click listener that listens for right clicks. Simo Ahava has some great advice about this. http://www.simoahava.com/analytics/custom-event-listeners-gtm/ The issue here is that, unlike a regular click, a right click doesn't guarantee that somebody will travel through a link.
The other would be to put custom code into either your buttons or your links that would allow you to track them without relying on the click listener in the first place. However, I suspect that this would be a lot more trouble than it's worth.
Upvotes: 5