├── FUNDING.yml
├── LICENSE
├── README.md
└── ga4.json
/FUNDING.yml:
--------------------------------------------------------------------------------
1 | github: thyngster
2 | ko_fi: thyngster
3 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2022 Analytics Debugger S.L.U.
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ## START IMPORTANT ANNOUNCEMENT
2 | 2023-06-27. Google Has officially announced AMP Support for GA4. I advise using the official integration rather than this one.
3 |
4 | https://support.google.com/analytics/answer/13707678
5 |
6 | https://twitter.com/googleanalytics/status/1673697311891812354
7 |
8 | ## END IMPORTANT ANNOUNCEMENT
9 |
10 |
11 | ## SUPPORT / DONATIONS
12 |
13 | Sponsor me here at GITHUB [](https://github.com/sponsors/thyngster) or buy me a coffee at
14 | [](https://ko-fi.com/Q5Q225ZVD)
15 |
16 | It's being a time consuming task to keep investigating this while Google decides to offer some proper official support,
17 | more even when I don't even run any AMP sites myself.
18 |
19 | I'm also hosting a copy of the configuration file on my own CDN for those who are not easily able to host it themselves, which actually gets (as of 02th Mayr 2023)
20 |
21 | - 3,94B hits
22 | - 13,09 TB Transfer BW
23 | - 1,03B Unique Visitors per month.
24 | - 36K DNS Queries/min
25 | - 588,51k Security Threats
26 |
27 | I'd love to go into a higher tier on the CDN to improve the setup and have a more reliable service.
28 |
29 | Since I'me giving my time for free would be great getting back some support from people/companies using this solution to being able to track their AMP sites.
30 |
31 | # Google Analytics for AMP
32 |
33 | AMP Analytics Config for Tracking AMP Pages using Google Analytics 4. This repository let you add a configuration file to your AMP setup in order to track your visits and users' interactions on Google Analytics 4.
34 |
35 | ## DISCLAIMER
36 |
37 | This isn't sponsored or supported in any way by Google, at the same time I don't know or there's any news about Google or AMP team to start giving official support to GA4 ( that's the reason for this project )
38 |
39 | ## SERVICE STATUS
40 |
41 | Because of the last outage of the CDN on Match 23-24th. We are currently monitoring the availability from NA, AU, EU and ASIA.
42 |
43 | [](https://betteruptime.com/?utm_source=status_badge)
44 |
45 | Status Page: https://status.analytics-debugger.com
46 |
47 | ## BLOG POST
48 |
49 | Full configuration and information on:
50 | https://www.thyngster.com/how-to-track-amp-pages-with-google-analytics-4
51 |
52 | ## Setup
53 |
54 | Just add the following code to your AMP Pages: ( check the table below for a full list of optional parameters and their functionality )
55 |
56 | ```javascript
57 |
58 |
73 |
74 |
75 | ```
76 |
77 | | Feature Name | Description |
78 | | -------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- |
79 | | GA4_MEASUREMENT_ID | Your `Measurement ID`, _**G-XXXXXXXX**_ |
80 | | GA4_ENDPOINT_HOSTNAME | Override the default endpoint domain. In case you want to send the hits to your own server or a `Server Side GTM` Instance. |
81 | | GOOGLE_CONSENT_ENABLED | a &gcs parameter will be added to the payloads with the current Consent Status |
82 | | WEBVITALS_TRACKING | If you enable this a `webvitals` event will fire 5 seconds after the page is visible |
83 | | PERFORMANCE_TIMING_TRACKING | Whatever you want to push a `performance_timing` event including the current page load performance timings |
84 | | DEFAULT_PAGEVIEW_ENABLED | If enabled a `page_view` event will fire on the page load |
85 | | SEND_DOUBLECLICK_BEACON | Send a DC Hit |
86 | | DISABLE_REGIONAL_DATA_COLLECTION | By default the data will be sent to the regional endpoint if the current user timezone name contains `Europe`) |
87 | | OVERRIDE_PAGE_LOCATION | Will override the default page url passed by AMP |
88 | | OVERRIDE_PAGE_TITLE | Will override the default page title passed by AMP |
89 | | USER_ID | If set the &uid will be passed back to hits. |
90 | | ENHANCED_MEASUREMENT_SCROLL | Will send an event to GA4, at 90%, same way as GTAG Enhanced Measurment does. |
91 |
92 | ## Suported Features
93 |
94 | - **Page Views**
95 | - **Event Tracking**
96 | - **User Properties** _(number and string)_
97 | - **Event Parameters** _(number and string)_
98 | - **Sessions Tracking**
99 | - **Session Engagements** (`&seg`)
100 | - **Sessions Count** (`&sct`)
101 | - **First Visits Tracking** (`&_fv`)
102 | - **Session Starts Tracking** (`&_ss`)
103 | - **AMP Cross-Domain**
104 | - **Engagement Time Tracking** (`&_et`)
105 | - **Screen Resolution**
106 | - **User's Browser Language**
107 | - **Document Title**
108 | - **Document URL**
109 | - **Document Referrer**
110 | - **Unique Pageview Id** (**`&_p`**)
111 | - **Debug Mode Switch** (**`&_dbg=1`**)
112 | - **Regional Data Collection** (**`region1.google-analytics-com`**)
113 | - **DoubleClick Data Tracking**
114 | - **Document Referrer**
115 | - **Cross Domain Tracking**
116 | - **User Agent Client Hints**
117 | - **Page Title, Page URL override**
118 | - **User ID**
119 | - **Conversions**
120 | - **Override Attribution Data, including: Source, Medium, Campaign, Term, Content, Id parameters.**
121 | - **Ignore Referral Support**
122 | - **Content Grouping**
123 | - **Page URL and Title Override**
124 | - **User Engagement Time**
125 | ## In-Build Events
126 |
127 | - **Web Vitals**
128 | - **Performance Timing**
129 | - **Scroll Tracking** (Enhanced Measurement)
130 |
131 |
132 | ## Cross-Domain Tracking
133 |
134 | To utilize the newly implemented core file session cross-linking feature, you can simply add a linker section to your `