What is Accelerated mobile pages

How to integrate google analytics code in your website

How to integrate google analytics code in your website

Step for Adding Google analytics code in your website

  1. Step 1 – Go to Google.com/analytics and login with your gmail account.
  2. Step 2 – Go to Admin Section and From the First Dropdown in the Account Column Select Create New Account.
  3. You will be asked to enter details of your new account like Website where you want to track using analytics code.
  4. Chose your website category accordingly.
  5. Click on Get Tracking ID and read terms and conditions and continue if you agree.
  6. You will get a script like this –
<script>

(function(i,s,o,g,r,a,m){i[‘GoogleAnalyticsObject’]=r;i[r]=i[r]||function(){

(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),

m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)

})(window,document,’script’,’https://www.google-analytics.com/analytics.js’,’ga’);

ga(‘create’, ‘UA-ABCDEFG-1, ‘auto’);

ga(‘send’, ‘pageview’);

</script>

Here UA-ABCDEFG-1 is your unique google analytics ID. Tracking ID

It can be accessed from your google account only or by any person with whom you share your google analytics data.

  1. Copy the code provided by GA from Step 6 and open the code of your website.
  2. Place (Paste in HTML) this code in every page of your website which you want to track. If your website is built using HTML and has pages like Home.html, About.html, Contact.html etc. Then you have to place this code just before the closing body tag of every HTML page.
  3. If your website is built using a CMS like WordPress then you can place your code in either header.php just before closing the header tag OR in footer.php just before closing the body tag. In my opinion, it is better to have analytics code placed in the footer because it helps in analyzing the website performance after the page elements have completely loaded.

Footer.php is located in: Dashboard >> Appearance>> Editor >> Footer.php

Since footer.php file executes on every page and post of WordPress, it is not necessary to place the code on all pages separately.

After placing the code wait for 2-3 days to get some data and click the home tab to see some analytics reports.

Leave a Comment