Google Analytics is a great, free tool you can use to gather all sorts of anonymous information about your visits. This tutorial will show you how to install Google Analytics tracking code on your Leafpub website — no programming required.

Get Your Tracking Code

The first step is to get your tracking code from Google Analytics. It will look something 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-XXXXXXX-XX', 'auto');
ga('send', 'pageview');

</script>

If you're new to this, first you'll want to create a Google Analytics property, then you'll be able to get your tracking code.

Install the Tracking Code

Now for the easy part. Navigate to Settings > Advanced and look for the Custom Code section. Paste your tracking code into the box for {{leafpub_foot}}.

custom-code.png

That's it! Hit Save and you're done. Now all the pages on your website will have the tracking code installed and data will start flowing to Google Analytics.