Who is visiting your website? Where are they coming from? What content are they engaging with and why? These are all questions you need a web analytics service in order to answer. Google Analytics is the most widely used web analytics on the internet. At its most basic the service tracks and reports on website traffic. However, this is just the beginning of what Google Analytics can do and a smart website owner will use it not just to count page visits but how to drive more.

In this mini-tutorial I will show you how to install Google Analytics on a static website created with Pelican.


You will need to sign-up for a Google account and activate Google Analytics


  • Implement the Google Analytics on all website pages

Installing Google Analytics

Sign-in to Google Analytics and click the gear icon to open up the settings menu. Click on the create property button.

some text

Fill-in all of the required information in the new property form. Ensure the website URL you enter is exactly the same as the domain which hosts our blog. Click the get tracking ID button when done.

some text

Make a note of the tracking ID that was generated for the website. We will be including it in our Pelican settings.

some text

Google Analytics only works on our published Pelican website. Open publishconf.py and uncomment the GOOGLE_ANALYTICS variable. Replace the tracking id below with your own.

GOOGLE_ANALYTICS = 'UA-135011604-2'

Now generate the website using publishconf.py

pelican content -s publishconf.py
pelican --listen

Once we upload the generated website to our host the Google Analytics service will begin tracking our website.


If you've been following along from the beginning we have now successfully installed Pelican, deployed a static blog to Github and even installed some 3rd party services to add extra functionality. I hope you've enjoyed working through this tutorial with me and I wish you the best on your web development journey with Python.


This article is part of a series of tutorials that will show you how to create static websites with Pelican And Python


comments powered by Disqus