Add Google Analytics to Your Websites

Anoob Bava
Thoughts on Tech
Published in
3 min readOct 24, 2018
copyright google

This blog is written on medium, A cool website in which we can blog and this can be viewed by millions around the internet. Medium has a lot of functionalities like blogging, stats, and indexing etc. Suppose you have a blog implemented using Jekyll or Octopress or a site and you need to track the sites visitors and other stuff, then google analytics is awesome for you. It is free to use for personnel as long as I believe.

I have a blog which is implemented using the Octopress, a framework which is implemented on top of Jekyll and used Ruby as a language and hosted using the GitHub pages.

What you need

  1. Sign up to Google Analytics
  2. Get the Tracking ID
  3. Add the script to your pages
  4. Allow Google Analytics

Sign up to Google Analytics

in order to do that to go to this link . The system will ask for your google details like email and password. after sign in, you will be redirected to a page where google analytics.

click on the signup option on the right. Will show you the details where we can analyze the page or mobile app, oh! yaa, it can track mobile app too. Then provide the other details like website name and url.

After giving the necessary details and click on the get tracking ID will give the tracking ID.

Get the Tracking ID

Now, we have received the tracking ID, then we need to link the tracking ID to your page.

Add the script to our pages

Below the tracking ID there is a javascript which is under the Global site Tag, copy the whole script to your websites.

<!-- Global Site Tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=GA_TRACKING_ID"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());

gtag('config', 'GA_TRACKING_ID');
</script>

Now replace the GA_TRACKING_ID with your own tracking ID and add this script to your html page. You can use your own index.html for this.

If we are using the Octopress, we can use the below config in the _config.yml also.

# Google Analytics
google_analytics_tracking_id: GA_TRACKING_ID

then you are awesome, you can view the live user access and the other details like country, page, bounce rate etc

that’s all, Please try out and comment if any issues, thanks for reading.

--

--