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
Use triggers with defined values to measure events in AMP pages. These properties are used in a trigger configuration:
selector: a CSS selector to specify a target element.on: specifies the type of event.vars: specify the type of event in event_name, and add additional parameters as necessary.This example demonstrates how to set up a basic Google Analytics event. Create a trigger called “button” that will fire when an element with an ID value of “the-button” is clicked. This trigger will send an event_name value of “login” and a method value of “Google” to Google Analytics:
Example code:
{
"vars": {
"gtag_id": "",
"config": {
"": { "groups": "default" }
}
},
"triggers": {
"button": {
"selector": "#the-button",
"on": "click",
"vars": {
"event_name": "login",
"method": "Google"
}
}
}
}Google Analytics Events are a category of events specific to Google Analytics that are commonly used to build reports on campaigns. These values can be specified in the vars block with event_category, event_label, and value parameters:
Example code:
{
"vars": {
"gtag_id": "",
"config": {
"": { "groups": "default" }
}
},
"triggers": {
"button": {
"selector": "#login",
"on": "click",
"vars": {
"event_name": "login",
"method": "Google"
}
}
}
}To override default Google Analytics parameters or add new parameters, add the desired values to the parameter section of your config block. This example overrides the default pageview and event values for page_title and page_location:
Example code:
{
"vars" : {
"gtag_id": "",
"config" : {
"": {
"groups": "default",
"page_title": "Beethoven symphonies",
"page_location": "https://www.example.com/beethoven.html"
}
}
}
}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:
If you want to check Google Analytics Event then you need to follow the below Screenshot.
You will find this option first log in to Google Analytics -> Reporting -> behavior -> Events -> Here is a list of Events Category.
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.…