简体   繁体   中英

Pass dynamic event label in Google AMP analytics event tracking

I want to track an event with google analytics when a link is clicked on my AMP html page. Also I want to pass the link(href) as eventLabel while tracking this event. Is there a way to set the link URL as data-* attribute which then can be passed to google analytics event tracking script. Or is there any other way to do this.

This is pretty standard thing but Google Analytics for AMP page doesn't cover it.

I think what you are asking for was recently made available here .

basically, you can use code like

<span id="test1" class="box" data-vars-event-label="22"> Click here </span>

and then use the value in the configuration as ${eventLabel}

It seems this is possible. AMP is now supported by Google Analytics as an extended component .

Events are user interactions with content that can be tracked independently from a web page or a screen load. Event tracking with clicked links can now be monitored like:

..,
"trackAnchorClicks": {
"on": "click",
"selector": "a",
"request": "event",
"vars": {
"eventId": "42",
"eventLabel": "clicked on a link"
}

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