Giter Club home page Giter Club logo

amp_google_analytics's Introduction

How to add Google Analytics to your AMP Webpage

  1. Set up Google Analytics
  2. Tracking ID
  3. amp-analytics
  4. Search Console
  5. Search Console link to Google Analytics

01 Set up Google Analytics

Create a Gmail account and log in to Google Analytics. Open the admin panel and add a new property:


02 Tracking ID

Fill out the form and click to generate a Tracking ID - which will look something like this "UA-88888888-1":


03 amp-analytics

Now we need to add the AMP Analytics script to our website inside the <head> tag:

<script async custom-element="amp-analytics" src="https://cdn.ampproject.org/v0/amp-analytics-0.1.js"></script>

The tracking ID can now be implemented inside the <header> tag of your AMP page, by adding the <amp-analytics> component:

<amp-analytics type="googleanalytics">
  <script type="application/json">
  {
    "vars": {
      "account": "UA-88888888-1"
    },
    "triggers": {
      "trackPageview": {
        "on": "visible",
        "request": "pageview"
      }
    }
  }
  </script>
</amp-analytics>

04 Search Console

Now we want to link our new property to the Search Console to get access to reports (e.g. you get information about AMP Errors and general tips to improve your HTML structure /SEO) and a list of keywords that lead Google Search users to your website.

Go back Property Settings:


And scroll down to "Adjust Search Console":


Click on "Edit":


And add your new property to your Search Console (this page will stay open in the background and you will have to refresh it after you added your new property - see final step):


You will then be asked to download an HTML file and upload it to the public /root directory of your website - to verify your ownership. Click on Verify and you are DONE!

05 Search Console link to Google Analytics

Now return to the previous page (still open in the background), refresh and select your new property - then click save:


As seen above, your Property is now linked in Google Analytics and you will start to see search results in your reports.

It might take a while for crawling information and potential Error Reports to arrive - give it a month... You will be notified by email if something was found in the need of fixing.

amp_google_analytics's People

Contributors

mpolinowski avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.