简体   繁体   中英

Google tag manager virtual page view not working for links that have span tags or images inside the link

I have one more issue which is strange. I set up a virtual page view in Google Tag Manager to listen out for PDF extension with reg ex. This works brilliantly.

If however there is a span tag inside said a-link or an image to represent the document the LinkListener rule does not fire at all. It will only accept text.

I've also tried using an onClick event to fire the virtual page view on links that have a span tag inside them. Removing the span tag from the text, they work as they should.

I'm using omnibus to help debug this. I'm not sure why it only accepts links with just plain text inside them.

this is how I have it set up:

Main Tag for the virtual page view

Tag Name = Virtual Pageview - PDF
Universal Analytics
Tracking ID = #######
Basic Configuration > Document Path = {{element url}}

The Rule that fires

Rule Name = PDF Click
Conditions >
    {{event}} equals {{gtm.click}}
    {{element url}} matches RegEx (ignore case) \.pdf$

When this is published it works fine for normal links with just plain text, not for those we have that wrap around span tags or images because we have them styled.

Note also because some of this content loads in with ajax, we are using the click event instead of the linkClick event.

Any help would be greatly appreciated.

Thanks

Andi

OK Changing the event conditions back to linkClick seems to work now.

Rule Name = PDF Click
Conditions >
    {{event}} equals {{gtm.linkClick}}
    {{element url}} matches RegEx (ignore case) \.pdf$

If anybody is interested this tutorial is simple yet the most effective I have found on the subject.

http://www.lunametrics.com/blog/2014/09/10/fire-virtual-pageview-google-tag-manager/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM