Posts Part 5 - Integrate Disqus comments and Google Analytics with Pelican
Post
Cancel

Part 5 - Integrate Disqus comments and Google Analytics with Pelican

This article is a part of a series of articles for web development using pelican. So, if you haven’t read the previous articles, please check it out by clicking the links below.

Creating and deploying static websites using Markdown and the Python library Pelican

Up to this point, you have created and hosted your static website on GitHub pages/custom domain and also learned to automate deployment.

Now, let’s integrate Disqus comment service system and google analytics into our site to analyze the in-depth detail about the visitors on your website.

I. Integrate Disqus Comments

  • Initially, go to the Disqus website and create an account. After creating your account, you will see 2 options as shown below:

disqus-options

  • Select the 2nd option i.e. I want to install Disqus on my site. Then fill up the fields like Website Name and Category as shown below.

disqus-create

In the website name field, you may enter any name for your website.

  • In the next step, you will have to select a subscription plan. Select the basic plan as shown.

disqus-plan

  • Then select I don't see my platform listed option as shown.

disqus-platform

  • Skip the installation step, go to the bottom of the page, and click Configure.

disqus-config

  • Add the website name (the GitHub page link or the custom domain if you have it linked) as shown below.

disqus-finalconfig

  • Go to Edit Settings and click General. There, you can see your Disqus website shortname in the Shortname field. Copy that name.

disqus-editsettings

disqus-shortname

  • Add the following line with the value copied from above to both the files publishconf.py and pelicanconf.py
1
DISQUS_SITENAME = 'ayushblog-2'

That’s it. You can check by using the command

1
(.venv) fab reserve

Then visit localhost:8000. At the bottom, you can see the Disqus comment section. Sometimes, it doesn’t appear in localhost. But don’t worry, it will still appear in the website.

disqus-comment

You can push the updated source code to view the changes on your website.

You can configure the appearance and other preferences of the comment system by logging in to this link: Disqus admin panel. You can also choose to moderate the comments before making it visible to the public. If you do so, you can moderate the comments by going to the moderate section of disqus. You can approve or delete the comment.

disqus-approve

Now, just push the source code and you are ready to go.

You can approve the comments by logging in to Disqus

II. Integrate Google Analytics

Now, let’s learn to integrate Google Analytics in our website.

analytics-create-name

  • Select Web and click Next.

analytics-create-web

  • Fill in the information as shown below and click Create.

analytics-create-property

  • Accept all the terms and conditions.

analytics-create-terms

analytics-tracking

  • Then, you will get a Tracking ID. Copy the Tracking ID and paste it in the file publishconf.py as shown below.
1
GOOGLE_ANALYTICS = "UA-166070073-1"

That’s all. Now just push the updated source code to the source branch and the analytics of your website will be tracked by google.

To view your detailed analytics, just log in to the Google Analytics website.

You can view detailed stats of your website visitors like the number of total visitors, active visitors, bounce rate, location of visitors. You can also view the real-time data of your visitors. How cool is that?

analytics

Congratulations!! You have completed the entire series of articles on Creating and deploying static websites using Markdown and the Python library Pelican.

If you have any confusion in any article, feel free to comment on your queries. I will be more than happy to help. I am also open to suggestions and feedbacks.

Also, you can use my GitHub repository for my blog post: ayushkumarshah.github.io as a reference in any point of the article. I have followed the same steps mentioned in this series to create my blog website that you are seeing right now.

If you want to visit any specific parts of the article, you can do so from the links below.

Or, go to the home-page of the article.

This post is licensed under CC BY 4.0 by the author.

Contents