en:user_advanced:google_analytics
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
en:user_advanced:google_analytics [2018/08/06 21:21] – kjdon | en:user_advanced:google_analytics [2018/08/07 02:16] – [Adding and using new servlet params] kjdon | ||
---|---|---|---|
Line 12: | Line 12: | ||
You add analytics account - you can have more than one. Eg we have New Zealand Digital Library account. | You add analytics account - you can have more than one. Eg we have New Zealand Digital Library account. | ||
+ | |||
+ | Inside your account, you can have lots of properties, which are websites. | ||
+ | |||
+ | Once you set up a property for a website, you get a snippet of code which goes into the head of all the pages in that website that need tracking. The code is common to all pages apart from the ID, which is unique to a property. In the following example, I have put UA-xxx as a substitute for the tracking ID. | ||
+ | |||
+ | < | ||
+ | <!-- Global site tag (gtag.js) - Google Analytics --> | ||
+ | <script async src=" | ||
+ | < | ||
+ | window.dataLayer = window.dataLayer || []; | ||
+ | function gtag(){dataLayer.push(arguments); | ||
+ | gtag(' | ||
+ | |||
+ | gtag(' | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | If you are writing this into XSLT file, you need to format it like this: | ||
+ | |||
+ | < | ||
+ | < | ||
+ | < | ||
+ | <!-- Global site tag (gtag.js) - Google Analytics --> | ||
+ | <script async=" | ||
+ | < | ||
+ | < | ||
+ | window.dataLayer = window.dataLayer || []; | ||
+ | function gtag(){dataLayer.push(arguments); | ||
+ | gtag(' | ||
+ | | ||
+ | gtag(' | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | </ | ||
+ | |||
+ | ===== Adding and using new servlet params ===== | ||
+ | |||
+ | To make this work I have modified the java code to store any initParams mentioned in the servlet definition (in servlets.xml) in the config_params HashMap. This gets passed to the transformer when it does the page transformation, | ||
+ | < | ||
+ | |||
+ | < | ||
+ | <!-- some global parameters - these are set by whoever is invoking the transformation | ||
+ | Any servlet init parameters can be accessed by adding a param here--> | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | |||
+ | </ | ||
+ | |||
+ | Now that this has been implemented, | ||
+ | |||
+ | In web/ | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | </ | ||
+ | |||
+ | </ | ||
+ |
en/user_advanced/google_analytics.txt · Last modified: 2023/03/13 01:46 by 127.0.0.1