In Analytics, it is common to send information on clicked links an analysis server. For example, "The external link was clicked" action is important. At the same time, we often see which link has transitioned.
However, in the current AMP Analytics, "URL of clicked link" is not defined in AMP variables.
Previously, we used data-vars-* attribute when it became necessary. But it is redunbant.
So, I suggest creating a CLICK_URL
AMP variables. Perhaps, it would be better to have CLICK_HOSTNAME
, CLICK_TEXT
, and other attributes, too.
Thanks
sorry for being late.
if it is to prevent redundancy, how about just improve the data-vars-
solution to check href
attribute if data-vars-href
is not given?
I'd prefer CLICK_HOST to be extracted by server. If anyone really need it client side, data-vars-host
shouldn't be the choice. Or, a generic solution is to wait for the filter (#2198) support.
We can consider a generic TEXT_CONTENT var if it is really something useful. And we will need to define a reasonable length limit (e.g. 100 chars).
Overall, as we are building a platform, the design principal here is to have something as generic as possible. We want a solution that is meaningful beyond click trigger.
@lannka I'm sorry that I noticed this comment now.
if it is to prevent redundancy, how about just improve the data-vars- solution to check href attribute if data-vars-href is not given?
I may not understand this comment correctly.
Is it correct by understanding the following preudocode?
func getDataVars(element, key) {
//return element.getAttribute('data-vars-' + key);
return element.getAttribute('data-vars-' + key) || element.getAttribute(key);
}
If so, I think it's good. Because we will be able to get other values(ex: src attribute of image tag, action attribute of form, etc).
In that case, it is essential to use the filter feature.
But, what does "I'd prefer CLICK_HOST to be extracted by server." mean?
Especially I do not know what "by server" represents.
@lannka How? Have you overlooked?
@1987yama3, @lannka is OOO. I can take a look at this later.
If so, I think it's good. Because we will be able to get other values(ex: src attribute of image tag, action attribute of form, etc).
Yes I think the idea here is correct. We may put some restrictions though, for example allowing this only for href
or src
, or only allow this for anchor element.
But, what does "I'd prefer CLICK_HOST to be extracted by server." mean?
Especially I do not know what "by server" represents.
As you also mention filter would the general solution here. One can use filter to get host from click url on client side.
Another option would be AMP sending out the entire click url to analytics server. And when analyzing those pings, one can handler the click url and extract click host on server side.
@zhouyx Thanks for your reply.
I think that it is not necessary to limit the attribute. I think that it is more convenient to get the id/class attribute and general data attribute, etc.
Why should you restrict attributes?
I think it is difficult to extract CLICK_HOST on the server side. Because it is the vendor side of each tool needs to deal with it and it can not be implement by the user of the tool.
Any update on this? I could make use of this feature to pull the href of a link on a click event
I'm sorry. There is no update. I am glad that someone will implement it instead.
We can start with creating a whitelist of data attributes that can be used when calling getDataVars.
@calebcordry has implemented the filter features, I think it makes sense to add macros to deal with the urls.
Hello, I was wondering what was left to do here? This would be extremely helpful for CMSs, like WordPress, where you have years of content with links that you can't easily go back and add data-vars-outbound-link
to. So if I knew what needs to be done, I can see if I can take up the reins.
I'm surprised that this issue hasn't been addressed. It's fairly common to include outbound click links in reporting for engagement tracking. It's awfully annoying to have to explicitly declare an extraneous data attribute on an element to be able to access that data from a trigger in an amp-analytics tag. Especially when that's the _only_ use case for using those attributes for some elements. And when all I want to access a simple href, it forces unnecessary redundancy.
Also, I second @Faison, this would also be particularly useful for content that directly pulled from a database like in a CMS.
Any updates on this?
This issue is currently on our low priority list because the functionality is already there. The proposal here is an optimization.
We're looking for help to implement this feature. Anyone willing to help?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.
Most helpful comment
I'm surprised that this issue hasn't been addressed. It's fairly common to include outbound click links in reporting for engagement tracking. It's awfully annoying to have to explicitly declare an extraneous data attribute on an element to be able to access that data from a trigger in an amp-analytics tag. Especially when that's the _only_ use case for using those attributes for some elements. And when all I want to access a simple href, it forces unnecessary redundancy.
Also, I second @Faison, this would also be particularly useful for content that directly pulled from a database like in a CMS.