Difference between revisions of "Adding Google Analytics to a Wiki"
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...") |
|||
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> | ||
+ | #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. | ||
+ | #Wait a few days for data to appear on your analytics page. |
Revision as of 16:15, 22 February 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:
- 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
- On the left side tab menu, lower corner, click the “Admin” button
- In the second column of the Admin menu, Click “Data Streams”
- Click the “>” at the end of the line for your stream
- In the “Tagging Instructions” section of the menu, expand the “Global site tag (gtag.js)” option
- 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>
- 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.
- Wait a few days for data to appear on your analytics page.