-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add element-level overrides for variables for amp-analytics #1298
Comments
@avimehta I think this is one of the next important projects. Could you put together a design? Let me know if you need any input. |
I'm interested in proving a |
@georgecrawford Can you detail the intended use of |
Nothing special, just a value I can send in my analytics payload to indicate the presence of a paywall barrier on the current page. |
Any further thoughts on this? |
@georgecrawford I don't think this issue will be able to address what you are asking for. Lets continue the discussion on #2476. |
👍 |
Hi, any word on when this will be complete? I'm working on implementing KISSMetrics tracking using amp-analytics, and this feature would really help with pushing custom event data to KM. (For example, when we send a clicked link event to KM, we encode the title of the linked page in a data-title attribute on the tag.) |
PRs are obviously welcome. We needed per-event variables to get this done and I sent out a PR for that recently. It should be a straightforward addition to support what this issue is asking for. Unfortunately as @rudygalfi mentioned, #1297 is higher priority for now. |
One suggestion would be to have the <a href="#deals" class="deals" on="track:p1233|m222|l111">Daily Deals</a> In this case if the One thing to note here, the same element can have other events associated with it. For e.g. it should also open a The other approach would be as mentioned above use a <a href="#deals" class="deals" data-track="p1233|m222|l111">Daily Deals</a> |
I personally like the second proposal. The negative of using the second proposal is that some data might have to be duplicated in @dvoytenko what do you say? |
I'll be pretty happy with a |
@dvoytenko In that case will attribute "track" will be whitelisted from the AMP validation? or can we go with "data-track" |
Yes, I'd prefer we whitelist |
@senthilp @rajkumarsrk Any interest in putting together a PR for this feature? |
Yes that is the plan. We are waiting on @avimehta to finalize the format for the |
I think your first comment about |
Option 1: "Prescribe only one attribute that can be specified by markup that amp-analytics reads and fills in" that @avimehta proposed looks like a good solve. But it should also have var substitutions as a part of it. Something like this would also work <a href="#menu" data-track="sw=${screenWidth}&sh=${screenHeight}&timezone=${timezone}">Link</a> Here the variables would be substituted and added to the request payload. Other than variable substitution we will not be doing any other processing on the Please let us know if this approach is ok and then we will start implementing it. |
@rudygalfi @avimehta Senthil and I liked option 1
Will it be like
And can we have the "vars" on the "data-track" override the event level definition, for example here we have "eventLabel". On click of link with text "Link 1", the "eventLabel" will be "clicked on a link 1" and click on link with text "Link 3" will be "clicked on a link" based on the value provided on "amp-analytics" tag. This way we can have the inline one overriding the event level definition on "amp-analytics" |
@rajkumarsrk One concern I have with what you're proposing is that
requires AMP to parse out name/value pairs. I do, however, like that there's a way to fallback to other variables defined as part of the config. I propose going with (2) mentioned previously, which is separate data-* attributes:
The part of the attribute name after the "data-" part will be interpreted as a locally defined variable name to enable usage like @cramforce @avimehta @dvoytenko Does this sound good to you? @senthilp Does this work? I know you'd proposed an alternative in #1298 (comment), but it seems like the option I described can work just as well. |
+1 to Rudy's comment. To recreate the example that @senthilp mentioned, we would do it as follows:
This ensures that any values provided by the publishers are opaque to AMP and AMP can just encode and add the values to the URL. With this format, the values can contain |
Given the complexity of values, +1 to option (2) with a per-var attribute. One question I have: should it be a |
I guess a couple things to consider are:
Perhaps something so clearly non-standard for the usual |
Some thoughts:
QQ: This is only for user event based analytics, right? So, the algorithm is:
correct? Agree, that we should not do structured values (name-value pairs) using a custom syntax. If the pure attribute based approach is insufficient, then AMP typically uses JSON encoded attribute values. |
If @cramforce 's flow is what we'd like, we should consider performance of scanning data attributes. In this case, a cheaper approach would be to:
|
@senthilp @rajkumarsrk Do you think traversing up the tree and collecting all the variables along the way is needed for you use? I was looking at the instrumentation code and I feel like we shouldn't do any traversal other than what is already done. We should look at only the element whose selector was specified in the config. So, if the config said "#button", we only look at that one element. If the selector is '*' or something that results in matching multiple elements, the event target should be used. This is both cheap and keeps things simple. We can use either |
@avimehta We do not need to traverse the tree and our use case doesn't require it. We will only look at the target element on which the event triggered and extract the |
@avimehta @senthilp While it might be better to use |
One more question: Which events would this apply to? I suppose it is urgent for click tracking, but I'm wondering if it would need to be supported elsewhere. |
This would apply to click targets for now. I think it could be applied to selectors in viewability trigger as well(We can implement this in future though if a request for it comes along). |
Cool, then lets just implement the |
Thanks @cramforce. @senthilp @rajkumarsrk Do you have all of the decisions you need to put together a PR? |
@rudygalfi Some clarification needed here is can we have all the vars as one group like |
I prefer |
Confirmed with @cramforce and @avimehta off-thread. We will go with |
@rudygalfi Thanks for confirming |
I think we have most of the information to begin implementation. We will work on it starting next week. |
Offshoot from #871.
More detail from @avimehta:
cc @btownsend
The text was updated successfully, but these errors were encountered: