Clicky

  1. Home
  2. How To
  3. How to add more parameters in Google Analytics for AMP

How to add more parameters in Google Analytics for AMP

Let’s see how to add Advanced Google Analytics like page, event, social tracking in AMP.

1. Enable the Options

You will find this option in the WordPress Admin Area -> AMP option panel -> Settings -> Analytics

  • Google Analytics: First enable the Google Analytics option and Enter the Analytics ID.

2. Add the Advanced Analytics Code

  • Advanced Google Analytics: Enable the Advanced Google Analytics option. As you can see there is a JavaScript editor to add the Analytics code in JSON format.
  • Change the “UA-xxxxxxx-x” with your Google Analytics ID.
  • Enter other tracking code in place of “// Enter your Advanced Analytics code here”.

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.

Ask your Questions Directly!
If you can't find the solutions in this article, then just ask us in the comments and we will answer it for you!
Updated on May 7, 2020

    Are you still looking for a solution?

    Then fill out the below form and we will reach out to you within a few hours.

    Was this article helpful?

    Related Articles

    Comments

      1. Hi Bulletin,

        Will you please elaborate more about your issue so that we will understand and help you.

    Leave a Comment