Analytics from Google is a powerful tool that helps you to collect deep insight from your website, blog and apps. The Google Analytics is loaded with tons of powerful tools including live insight of the hits and visits on your website. The Google Analytics is integrated by placing the snippet of JavaScript code which may not execute on the browsers with JavaScript turned-off and because of this, you may miss out most of the insight. This article will guide you in implementing and deploying Google Analytics on your Website or Blog without JavaScript.
You need to have Google Analytics code. You can ignore step-1 if you have Google Analytics code else if you don’t have you can learn and can get by following below instruction-
On Clicking Tracking code option some JavaScript will appear in the right side of the sidebar menu, for your convince example is given below:
<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','//www.google-analytics.com/analytics.js','ga'); ga('create', 'UA-123456789-1', 'yourwebsite.com'); ga('send', 'pageview'); </script>
<img src="https://nojsstats.appspot.com/Your-Site-tracking-here/yourwebsite.com"/>
Now copy above code and paste it anywhere on your website or blog. You can also use the <noscript> tag to tell the Browser to include only in case of JavaScript is disabled. See below example:
<noscript><img src="http://nojsstats.appspot.com/Your Site tracking here/yourwebsite.com"/></noscript>
Since the first above method has depreciated, we have another method to track Google Analytics insight without JavaScript.
You need to insert an image wherever you want to deploy the tracking without Javascript with the help of <img> tag or CSS background property loading image from https://ssl.google-analytics.com/collect and passing the important parameters with values.
Parameter | Description |
tid | Your GA tracking ID in format UA-123456-XX |
z | Any random string to prevent the browser caching. You can use the PHP rand() function to generate a random string. |
v | Google analytics version by default, it should 1 |
t | Events to be tracked by default it should be the event |
ea | Encoded URL that to be tracked; you can use urlencode() in case of PHP |