-
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
Intent to Implement: Analytics APIs for AMP #871
Comments
CC @rudygalfi |
I'm working on a related doc to create the "client identifier". Will publish in the coming days and link here. |
Is data like geo and device type accounted for in some way? |
Would be great to get the segment guys to use this as that would be one gateway to support many platforms without each analytics platform needing to create their own |
@rudygalfi geo is usually calculated from IP address. Apart from that, the timezone (which is part of spec) is another hint. There is the option of asking browser for location but I am not aware of any vendor that uses that API. I'll look into the device type a little more. So far the signals available for device type inference are the useragent and the screen resolution. |
Just posted #961 regarding client identifiers. |
@avimehta IP doesn't seem to be listed in the spec at the moment. Is that an oversight? |
Is the current intent that you either have an inline config, or config over a URL, or is there an intent to support merging the two? Keeping it to one or the other seems perfectly reasonable, but it would be good to be explicit. |
@philwills I don't believe the client has any way to read the IP even if it wanted to. It would be available server side on the outbound beacon request. As to the intent of multiple configs: We plan to support multiple layers of config. Basically:
They all get mixed into the same large JS object with configs further down having the ability to override values defined further up. |
@cramforce So is there some view identifier intended to be consistently available to the outbound beacon and the analytics API enabling us to tie the two together? Apologies, I'm still trying to get my head round AMP at the moment and am not quite sure where some responsibilities lie. |
@philwills I posted about client identifiers yesterday in #961. Not sure whether a view identifier (just a random value that is the same for all requests from the same page view?) is planned, but would certainly be straight forward to add. |
Just merged the client identifier PR #963. You can now do |
Mostly what @cramforce said. re IP: @philwills IP is something that servers have to log on their side. javascript has no access to it. User-agent is another thing that is sent as part of http request so javascript won't deal with it(unless there is really some need for user-agent in javascript. If this is the case, please explain and I'll include it.) re Merging: I think the intent is to do the merging but the details of how we end up doing the merging and the order of precedence is TBD. Would https://github.com/google/data-layer-helper#the-abstract-data-model merging logic work for you? re View Identifier: This part is still TBD but there is no reason this can't be supported. |
@avimehta We use user-agent for analytics and for customizing experiences in different in-app contexts and for different device types. For example, we might use a different SMS sharing icon if you're on Android, or we add a more prominent "Pin It" button if you're in the Pinterest app. For in-app, the referrer usually shows as direct. Pinterest, Facebook, and Twitter modify the user-agent though so we detect that and add a class to |
@ryanlombardo please take a look at #945. I think it covers some of the examples you mentioned and I'd like to get your feedback. |
+1 to what @rudygalfi said. @ryanlombardo I am still trying to understand the usecase so pardon my ignorance: The examples you mention are related to changing something based on the environment ( You also mentioned overriding the ps: fwiw, adding |
In the examples there's an +1 re: Known Issue: Heuristics for active engaged time are TBD. Maybe use an open-source implementation -- however, this can also be approximated on the server side by comparing scroll_x|y values across timer pings, so I wouldn't consider it a blocker. Also, +1 re: external / linked configs -- this is critical for allowing publishers to define an internal user ID in the analytics config for submission to analytics providers. |
@rudygalfi #945 would work. It's similar to what we're doing for that type of customization. @avimehta We do it on the client-side. Google Analytics and Adobe Analytics have methods for overriding the referrer. I agree that mappings may need to change overtime and probably isn't the best solution. How would your server-side proposal work? |
We will try our very best not to use unload events. They are bad for
|
Different topic: Is there a way to pull parameters out of the URL? Example: |
I am planning to expose the query and anchor parts in the doc. If there is GA can use this for campaign stuff. Probably a lot of other vendors might On Mon, Nov 23, 2015 at 3:41 PM, rudygalfi notifications@github.com wrote:
|
We would definitely like to pull out UTM parameters from the URL. Sent from my iPhone
|
@avimehta I think as far as the analytics framework is concerned it's not necessary to parse out the params. Should there be entries in the design proposal listing the query and anchor parts as built-in variables? |
@avimehta I am aware that the IP isn't available in JS. I'm still getting to grips with AMP and wasn't sure whether the intent for this was to have the client talk back to the analytics system directly, or if that was to be intermediated. |
Validation fails when analytics are added. |
How do I get the ball rolling on the implementation of active engaged time? In the last couple of check-ins with Josh from Chartbeat and Andrew from Parse.ly, we agreed to move forward with active engaged time once we had a universal definition; we think we are now there. To summarize, each second (or time interval) we count someone as being engaged if the user has the window in focus and has interacted with the page during the last five seconds. Chartbeat uses [pageload, focus, mousedown, mousemove, scroll, keydown, resize] as a minimal set of event interactions. The reason we don’t include mobile-specific events (e.g., touchstart, touchenter) is that some of our client sites have had performance issues with the handling for these events. Instead, we leverage the fact that essentially all mobile browsers fire desktop mouse/scroll events at the end of a touch tap to better accommodate legacy web pages. The only other substantial difference between Parse.ly’s open source implementation (https://github.com/Parsely/time-engaged) is that we will not consider video in the AMP definition. |
@breauxc Is it worth spawning a separate issue to track this? This one is rather sprawling already. |
Once the bulk of the initial implementation for AMP Analytics is complete, I’d like to be able to close this issue and continue discussions for further feature requests in other issues. To that end, I have opened issues relating to several items that were called out as TODOs in the design or raised as comments on this issue.
Also, relating to the discussion about the view identifier, this should be supported via the PAGE_VIEW_ID substitution as documented here: https://github.com/ampproject/amphtml/blob/master/spec/amp-var-substitutions.md. (So you could construct it as something like I believe the suggestion of adding a POST option is covered by the It should be possible to specify more than one host since the |
…oject#871 Also updated the docs for clarity and fixed a typo.
Added documentation about variables supported by amp-analytics. #871
I've opened two additional issues to track work first mentioned in this issue:
|
…oject#871 Also updated the docs for clarity and fixed a typo.
Will this support custom dimensions for Google Analytics? |
@alvin-milton The Google Analytics support does include custom dimensions, according to https://developers.google.com/analytics/devguides/collection/amp-analytics/#extending_googleanalytics |
@alvin-milton @rudygalfi not exactly, since theres no optional parameter support, any custom dimensions you want to include have to be explicitly defined in your own request like the example given by rudy. So yes you can define whatever parameters you want for GA as long as you add the query string for it in the request object |
Analytics APIs for AMP
Objective
Define a vendor-neutral method for adding analytics to an AMP document.
Overview
A new tag,
<amp-analytics>
, defines which events to measure and how the measured data is sent to an analytics vendor.This tag provides built-in support for most widely used analytics services. For example, the following tag will send measurement requests to XYZ when the document is loaded, and when any element matching the
.page_button
selector is clicked.Alternatively, this tag can be used to send the analytics data to a custom endpoint, request format and transport.
In both these tags, a simple templating mechanism is provided to replace
{{identifier}}
tokens with properties extracted from either (in descending precedence) the DOM event target element, the event configuration object, the amp-analytics configuration object, or platform provided built-in properties (for examplecanonical_url
orreferrer
). This system allows declarative access to document properties.Details
A publisher can configure the
<amp-analytics>
tag and use the JSON config to listen for various events and filter on elements using css selectors. There should ideally be only one tag per analytics vendor.Analytics Tag
Each analytics vendor's configuration lives in an
amp-analytics
tag. The configuration that goes with the tag can be either inline or defined through an external JSON resource.type
: An optional string that identifies certain pre-defined analytics services. If none is specified, the JSON config should contain thehost
andrequest
values to send the analytics data to.config
: This is a URL to a JSON resource that defines the config to be used with this analytics tag. Details on the format of the config are below. This method allows the publishers to self-host the config or manage the configurations through third parties like Tag managers etc and makes the analytics on a page dynamically configurable. The transport for the URL specified here should always be https.JSON Config
The details about how the hits for a particular vendor are fired can be specified in the JSON config. This config follows the same format for various types of analytics tags above.
host
: This field describes the host to which the analytics data is sent. The scheme is always https.requests
: This object defines templates that specify the request payload to be sent to an analytics host. Requests can use variables that are defined by the platform or by the publisher elsewhere in the config. If a variable can't be resolved, an empty string is used for the value.vars
: The JSON config can contain any number of named properties. These properties are used to fill in the request templates. Values of variables that are filled in from templates will be document encoded before insertion into the URL.Variable values are defined in various places. In increasing order of precedence:
triggers
: This field defines an array of events that are measured by the analytics vendor. Each value in the array is an object with key-value pairs defined below.on
: This value defines the DOM event that is used as the trigger for the entry. Valid values for this field are:tap
: When one of the elements in the selector list is tappedclick
: when one of the elements in selector list is clickedvisible
: When the document is made visiblehidden
: When the document is made invisibletimer
: Based on a timer which is defined through a timer-spec.request
: Name of the request template to use for analytics requests.selector
: This is a comma separated list of selectors that will be listened to for the DOM event. This field accepts one or more comma separated list of CSS selectors that the the native browser will accept through document.querySelectorAll().Built-in Variables
Page
domain
: AMP document's domainpath
: AMP document's pathcanonical_url
: The canonical URL for the AMP documenttitle
: AMP document's titlepage_authors
: Authors if specified in the page's schemapage_section
: Section details specified in the page's schemaUser metadata
client_id
: An id associated with the user (persistent). This id will be generated by the runtime and the spec will be published soonclient_timezone
: Timezone read from the browserBrowsing data
referrer
: Referrer to page, if any. The analytics vendor has to determine if the traffic is considered as organic/referrer/directtimestamp
: The timestamp of when the hit is generated.Browser data
screen_width
,screen_height
: Dimensions of the screen.Scroll depth
scroll_x
,scroll_y
: Current scroll depth as offset from top of page, pixelsmax_scroll_x
,max_scroll_y
: Maximum scroll depth attained as offset from top of page, pixelspage_height
: Current height of page, pixelsAMP data
is_proxied
: A flag indicating that beacons are coming from an AMP pageruntime_id
: Platform descriptor: A descriptor of which domain/app the AMP file is being viewed fromTiming
page_load_time
: Page load time (ms)Misc
random
: A random string generated for each hit.developer_mode
: true/false indicating whether the developer mode was turned on.hit_count
: Total number of hits sent to the analytics vendor.Examples
Note that the named examples below are just meant to show how things could be implemented. They are not really implemented yet.
Custom URL
Built-in tag for Google Analytics
Built-in tag for chartbeat
Remote config
Known Issues
on
semantics for first-visible, long-view and other events.Edits: Removed external link.
The text was updated successfully, but these errors were encountered: