1
Step1. Enables GA User-ID
https://support.google.com/analytics/answer/3123662Step2. Add Track code in your xoops template
use new track code (gtag.js) <script async src="https://www.googletagmanager.com/gtag/js?id=GA_TRACKING_UAID">script>
<{if $xoops_isuser}>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'GA_TRACKING_UAID', { 'user_id': '<{$xoops_name}>' });
script>
<{else}>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'GA_TRACKING_UAID', { 'user_id': '<{$smarty.const._GUESTS}>' });
script><{/if}>
if use old code (analytics.js) <script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'GA_TRACKING_UAID', 'YOUR_DOMAIN_NAME');
<{if $xoops_isuser}>
var xoopsuser_name = "<{$xoops_name}>";
ga('set', 'userId', xoopsuser_name );
<{/if}>
ga('send', 'pageview');
script>
Clear Template Cache
now you can track your xoops user log detail in Google Analytics
reference
https://developers.google.com/analytics/devguides/collection/gtagjs/migrationhttps://developers.google.com/analytics/devguides/collection/gtagjs/cookies-user-idhttps://developers.google.com/analytics/devguides/collection/gtagjs/setting-valuesthanks , i'm come from taiwan. (not china)
my english very pool , so embarrassed
My Blog
https://3q.9527.tw/103