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/analytics/devguides/collection/gtagjs/migration
https://developers.google.com/analytics/devguides/collection/gtagjs/cookies-user-id
https://developers.google.com/analytics/devguides/collection/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: 11409

  • Since: 2004/4/23


Thanks for sharing!

And you English is fine, so don't worry about it!
Support XOOPS => DONATE
Use 2.5.11 | 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

4
JammerPro
Re: Track Xoops user detail in Google Analytics
  • 2022/11/11 5:02

  • JammerPro

  • Just popping in

  • Posts: 39

  • Since: 2008/8/24


Hi gentlemen... Well, Google has now taken Google Analytics to Version 4. We need to add more info like a "MEASUREMENT ID" and more. I forgot where I put the initial code with just the property number. Can someone please refresh where to paste





Thanks in advance!

5
kakos
Re: Track Xoops user detail in Google Analytics
  • 2022/11/16 7:08

  • kakos

  • Friend of XOOPS

  • Posts: 79

  • Since: 2002/6/6 2


You can paste it in the your theme. Look at header section where the rest of the javascripts are .

Login

Who's Online

417 user(s) are online (299 user(s) are browsing Support Forums)


Members: 0


Guests: 417


more...

Donat-O-Meter

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

Latest GitHub Commits