Section 29.7 Analytics
PreTeXt makes it as easy as possible to have services provide data about visitors to the HTML version of your book. We support Google Analytics
StatCounter uses two identifiers, a
projectID and a
securitycode. Do not copy the identification numbers from another project—be sure to obtain your own for your project. You can find them in your “Project Config” under “Settings”. Or the code provided will contain lines such as
var sc_project=11538430; var sc_invisible=1; var sc_security="72e1390a";
In which case your publication file would have an element under
<analytics statcounter-project="11538430" statcounter-security"72e1390a"/>
Google Analytics comes in several flavors. We once supported Classic and Universal, but no longer, so we do not provide documentation here. For the replacement, Google Global Site Tag is a single ID. Do not copy the identification numbers from another project—be sure to obtain your own for your project. Google once called this a tracking ID, which may also be called a property ID; these looked like
UA-6836004-1. Google has now switched to Google Analytics 4 and is exclusively using the form of a Google Tag ID/Measurement ID which will look similar to
G-CQG9X37H61; you will need to upgrade your analytics if you used the older style tag. In any case your publication file would have an element under
If you use both services, you can elect to use just one
<analytics>element with several attributes.
We would be happy to provide support for additional major services. Just make a feature request.