XF 1.5 How to record Google Analytics event tracking when clicking user profile tabs?

Stuart Wright

Well-known member
Hi Folks,
so I want to add an event into Google Analytics every time someone clicks the tabs on user profiles so we can see how much they are getting used.
Let's take the Information tab as an example

In the member_view template, the heading for the tab is
Code:
<li><a href="{$requestPaths.requestUri}#info">{xen:phrase information}</a></li>
should I add
Code:
onclick="ga('send', 'event', 'User Profile Tab', 'Click', 'Information', {$requestPaths.requestUri});"
to get
Code:
<li><a href="{$requestPaths.requestUri}#info" onclick="ga('send', 'event', 'User Profile Tab', 'Click', 'Information', {$requestPaths.requestUri});">{xen:phrase information}</a></li>

Would this correctly track clicks of the Information tab?
(I'd want to put the userid in there rather than the URI, but I don't know what that is at this stage.)
And would it not be sensible for Xenforo to track this kind of interaction as standard?
 
Last edited:
Top Bottom