Pass dynamic event label in Google AMP analytics e

2019-05-22 00:42发布

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.

2条回答
再贱就再见
2楼-- · 2019-05-22 01:33

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}

查看更多
混吃等死
3楼-- · 2019-05-22 01:35

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"
}
查看更多
登录 后发表回答