Add Google Tag Manager to Pelican CMS

How to add Google Tag Manager to Pelican CMS

Let's see how to add Google Tag Manager to Pelican CMS

Using the ANALYTICS setting in pelicanconf.py will add the script in the footer of the page. But we want it at the start of head and body tag as per Google Tag Manager instructions.

So, the easiest way to do this I found was to edit your theme's base.html file and add the code there.

For this copy theme folder to the same folder as pelicanconf.py and add add below setting to pelicanconf.py

THEME = "themes/your-theme-name"

This will make sure that pelican uses the theme from the local folder and just edit the base of pages to add the Google Tag Manager code.