Let’s see how to add Advanced Google Analytics like page, event, social tracking in AMP.
You will find this option in the WordPress Admin Area -> AMP option panel -> Settings -> Analytics
Example code:
"trackEvent": {
"selector": "#event-test",
"on": "click",
"request": "event",
"vars": {
"eventCategory": "ui-components",
"eventAction": "click"
}
}You can insert title, URL, and id as {title}, {url} and {id} respectively.
For example:
"url": "{url}",
"title": "{title}",
"id": "{id}"URL, Title and post ID can be passed shown below.
"trackEvent": {
"selector": "#event-test",
"on": "click",
"request": "event",
"vars": {
"eventCategory": "ui-components",
"eventAction": "click",
"url": "{url}",
"title": "{title}",
"id": "{id}",
"author-id": "{author_id}",
"author-name": "{author_name}",
"category": "{category}",
"published-at": "{published_at}",
"tags":"{tags}",
"seo-score":"{seo_score}",
"focus-keyword":"{focus_keyword}"
}
}Before adding this two variable make sure you need to activate Yoast SEO plugin.
After adding another tracking code, your code should look like this:
Note: This is just an example code used only for demonstration purpose.
I hope this tutorial helps you to successfully add the Analytics on your site and If you encounter any issue you can reach us for the help here.
Google Documentation for AMP analytics: https://developers.google.com/analytics/devguides/collection/amp-analytics/
That’s it for this tutorial!
We hope it helped you. If you have any feedback or questions, then please share them in the comments section below.
If you want to add an AWeber form in AMP then first you need to…
Webpushr is the fastest growing web push notifications platform that marketers love & developers rely…
Follow these steps to add Adobe Analytics in AMP Step 1: Go to WordPress Admin Area -> AMP…
Core Web Vitals are the subset of Web Vitals that apply to all web pages,…
The following reasons can be shown for non-indexing. Server error (5xx) Your server returned a 500-level…
We have added the Google Analytics 4 ( GA 4 ) integration in AMPforWP v1.0.80.…