Topic-icon Tracking users first login on Google Analytics

Active Subscriptions:

None
Yes... I like to complicate things, but here it goes...
I need to track objectives on Google Analytics (GA). One of the objectives is "User Registration". GA tracks objectives by counting certain URL pageviews.

So, I could redirect the users on first login to some "thank-you-for-registering" page, and that would work ok for GA
But I do not want to do that, I want users to stay on the same page when they login for the first time (and all times).

So, this can be done with a GA Javascript bit of code that triggers a "virtual pageview" to that "thank-you-for-registering" page.
Now, questions:
  • if I echo that Javascript call at jfbcProfilesOnRegister() (on a jfbcprofiles plugin) will it work?
  • or is there a way (via JFBConnect function, cookie value, whatever) to determine "this is the user's first login - so shoot the virtual pageview"?

Thanks a lot.



Yes, I could redirect the users to some "thank you for registering" page
The topic has been locked.
Support Specialist
14 years 8 months ago #14151 by alzander
Alexandre,
I've used the virtual pages for Google Analytics in the past, but not for what you're looking for (and not with JFBConnect). I can't think of a 1-liner that will do what you're shooting for, but the below snippets should help. All changes are in the com_jfbconnect/libraries/facebook.php file.

First, find the "setInitialRegistration" function. Add the following to it, which will set that this has been an initial registration, so we can detect on the next page view (new user redirection):
$session =& JFactory::getSession();
$session->set('jfbcInitialRegistration', true);

Then, at the bottom of the initDocument function, directly below, add this code:
$session =& JFactory::getSession();
if ($session->get('jfbcInitialRegistration', false))
{
  $session->clear('jfbcInitialRegistration');
  $doc->addCustomTag('<script type="text/javascript">Call virtual Page JS here</script>');
}
Code above looks good, but completely untested. Hope it works for you, but let us know if you run into anything,
Alex
The topic has been locked.