Add analytics.js
to your add-on pages. Update the tracking code and Add-On / Macro Name and you should be good to go.
You'll need to add some custom dimensions in Google Analytics. Use the names in comments in the section of analytics.js
below // Add into custom dimensions
Note that you must not store PII such as user_id
which is sent over to Google Analytics in every request as a request parameter. Note userKey
is not PII, so can be used.
To remove user_id
, in Google Analytics > Admin > Reporting View Settings, add user_id
in Exclude URL Query Parameters