Difference between revisions of "Adding Google Analytics to a Wiki"

From apimba
Jump to navigation Jump to search
(Created page with "Assume that a google analytics account is already set up and functioning for the standard html web page fronting your wiki and that the headscript extension is installed for y...")
 
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
Assume that a google analytics account is already set up and functioning for the standard html web page fronting your wiki and that the headscript extension is installed for your wiki software.
+
I tried following the mediawiki instructions for adding google analytics to my wiki but they did not work. After much trial and error, the following procedure was found to work fine:
 +
 
 +
#Assume that a google analytics account is already set up and functioning for the standard html web page fronting your wiki and that the headscript extension is installed for your wiki software.
 
#Log into Google Analytics
 
#Log into Google Analytics
 
#On the left side tab menu, lower corner, click the “Admin” button
 
#On the left side tab menu, lower corner, click the “Admin” button
Line 13: Line 15:
 
<p>gtag('config', 'G-01NDZHCJMM');</p>
 
<p>gtag('config', 'G-01NDZHCJMM');</p>
 
<p></script></p>
 
<p></script></p>
 +
#<li value="8">Check that the text is showing up on your wiki pages by right clicking a page and select "view page source". The text should be in the <head> section of the web page.</li>
 +
#Wait a few days for data to appear on your analytics page.

Latest revision as of 18:02, 22 March 2022

I tried following the mediawiki instructions for adding google analytics to my wiki but they did not work. After much trial and error, the following procedure was found to work fine:

  1. Assume that a google analytics account is already set up and functioning for the standard html web page fronting your wiki and that the headscript extension is installed for your wiki software.
  2. Log into Google Analytics
  3. On the left side tab menu, lower corner, click the “Admin” button
  4. In the second column of the Admin menu, Click “Data Streams”
  5. Click the “>” at the end of the line for your stream
  6. In the “Tagging Instructions” section of the menu, expand the “Global site tag (gtag.js)” option
  7. Copy the text in the window and place it in your LocalSettings.php file for your wiki. The text will be similar to below, where G-01NDZHCJMM is a user specific code so yours will be different (In other words, do not use G-01NDZHCJMM)

<script async src="https://www.googletagmanager.com/gtag/js?id=G-01NDZHCJMM"></script>

<script>

window.dataLayer = window.dataLayer || [ ];

function gtag(){dataLayer.push(arguments);}

gtag('js', new Date());

gtag('config', 'G-01NDZHCJMM');

</script>

  1. Check that the text is showing up on your wiki pages by right clicking a page and select "view page source". The text should be in the <head> section of the web page.
  2. Wait a few days for data to appear on your analytics page.