-
-
Save panbanda/a776f58c72c237269eef to your computer and use it in GitHub Desktop.
Use Google Analytics in AMP HTML
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<amp-pixel src="https://ssl.google-analytics.com/collect?v=1&tid=UA-12345678-1&t=pageview&cid=$RANDOM&dt=$TITLE&dl=$CANONICAL_URL&z=$RANDOM"></amp-pixel> | |
/* | |
* Required parameters: | |
* v = API version number (currently 1) | |
* tid = Google Analytics property identifier (UA-12345678-1) | |
* t = hit type | |
* cid = client id (you should implement this via cookie etc.) | |
* z = random string to bypass caching (amphtml generates this to $RANDOM variable) | |
* | |
* Some nice to have parameters: | |
* dt = document title ($TITLE) | |
* dl = document location ($CANONICAL_URL) | |
* | |
* References: | |
* https://github.com/ampproject/amphtml/blob/master/builtins/amp-pixel.md | |
* https://developers.google.com/analytics/devguides/collection/protocol/v1/reference | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment