02-22-2021, 02:21 PM
This tutorial will help you enable tracking User-ID features in Google Analytics (default in Xenforo only tracking pageview and auto event by Google)
Step 1: Follow guide on https://support.google.com/analytics/ans...3666?hl=en to create new User-ID View on GA.
Step 2: Login your Xenforo Admin -> Appearance -> Templates -> find template name: google_analytics
Find
Code:
<xf:if is="$xf.options.googleAnalyticsAnonymize">
'anonymize_ip': true,
</xf:if>
Code:
<xf:if is="{$xf.visitor.user_id}">
'user_id' : '{$xf.visitor.username}',
</xf:if>
Reference
- https://support.google.com/analytics/answer/3123666?hl=en
- https://developers.google.com/analytics/devguides/collection/gtagjs/cookies-user-id
- https://xenforo.com/community/resources/conditional-statements-for-xenforo-2.5795/