1
xd9527
Track Xoops user detail in Google Analytics
  • 2018/1/31 9:21

  • xd9527

  • Just popping in

  • Posts: 8

  • Since: 2016/1/13


Step1. Enables GA User-ID
https://support.google.com/analytics/answer/3123662

Step2. 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/analytic ... llection/gtagjs/migration
https://developers.google.com/analytic ... on/gtagjs/cookies-user-id
https://developers.google.com/analytic ... ion/gtagjs/setting-values

Resized Image
Resized Image

thanks , i'm come from taiwan. (not china)
my english very pool , so embarrassed

My Blog
https://3q.9527.tw/103

2
Mamba
Re: Track Xoops user detail in Google Analytics
  • 2018/2/2 8:26

  • Mamba

  • Moderator

  • Posts: 11251

  • Since: 2004/4/23


Thanks for sharing!

And you English is fine, so don't worry about it!
Support XOOPS => DONATE
Use 2.5.10 | Docs | Modules | Bugs

3
xd9527
Re: Track Xoops user detail in Google Analytics
  • 2018/2/5 1:49

  • xd9527

  • Just popping in

  • Posts: 8

  • Since: 2016/1/13


thank you Mamba
can add GA code in system maybe next xoops vertion
like wordpress have this function

Login

Username:
Password:

Lost Password? Register now!

Who's Online

67 user(s) are online (37 user(s) are browsing Support Forums)


Members: 0


Guests: 67


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Jun 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits