How to Setup Google Analytics in ↓markdown↓ CMS
To get a website that meets the needs of the visitors' using it is worth understanding who they are. This can be achieved through collecting meta-data about the page requests made to the website. The Google Analytics service can provide reports on such web page meta-data and in more detail than just looking at a web server's log files. A website that uses the ↓markdown↓ CMS software can enable Google Analytics support.
Create a Google Analytics Account
To enable Google Analytics in ↓markdown↓ CMS (here abbreviated to md-CMS) you will require a Google Analytics account. You then add your website to that account. This allows you to obtain a Measurement Id, also known as the Tracking Id or Tag Id. Then md-CMS uses that Id as a setting to trigger adding the Google Analytics provided script called gtag.js to your website pages.
Configuring Google Analytics in ↓markdown↓ CMS
When building a website with md-CMS it can automatically use Google's gtag.js script. For it to operate, it requires your website's Google Analytics Id in the md-CMS configuration file. When md-CMS sees the Id in the configuration file it adds the gtag.js script to the web page being sent to the user's browser. If are in the process of installing md-CMS then setting up the configuration file is covered in Website Home Page for ↓markdown↓ CMS.
To add the Google Analytics Id to the website's md-CMS configuration file use your website's control panel and edit the site-config.php file. Add the entry
TRACKING-ID in the
$MD_SETTINGS array, setting the value to the Google Analytics Id for your website (see your Google Analytics account). For example, if the Tracking Id was AB-12345678-9:
. . . "TRACKING-ID" => "AB-12345678-9", "XML_SITEMAP_REFRESH" => "-1 week" );
Once the updated configuration file is saved on the web server the Google Analytics script is enabled. The script appears within all the web pages that use the md-CMS system for publishing, and with the correct Tracking Id.
To stop the Google Analytics script from being added to the web pages remove the Tracking Id line from the site-config.php configuration file.
- There are more tutorials covering md-CMS in the article Build a Website from Scratch with ↓markdown↓ CMS.
- Enabling the md-CMS configuration file is covered in Website Home Page for ↓markdown↓ CMS
- For a full list of the articles on Tek Eye see the full site Index
Author:Daniel S. Fowler Published: Updated: