Topic-icon Google Analytics tracking

Active Subscriptions:

None
12 years 2 weeks ago #21067 by jwhelan
Alex,

I've gotten Google Analytics working on my site and want to track user registrations as follows:

1) New user clicks on 'Login with LinkedIn' and is directed to registration page (event 1)
2) New user correctly completes registration page and is 'Successfully connected to LinkedIn' (event 2)

And, I'd like to track the following:

1) Existing user 'Logs in with LinkedIn' (event 3)

Do you have any best practices you's suggest with Google Analytics to track these actions?

Thanks again.

-JW
The topic has been locked.
Active Subscriptions:

None
12 years 2 weeks ago #21114 by jwhelan
Replied by jwhelan on topic Google Analytics tracking
I figured out one of the parts above - how to track an event when the new user clicks on 'Login with LinkedIn' and gets directed to the registration page. But, I'm still trying to figure out where to trigger a javascript event for analytics purposes to monitor the following:

1) New user correctly completes registration page and is 'Successfully connected to LinkedIn'

2) Existing user 'Logs in with LinkedIn'

I'm thinking I should be looking at the controllers/loginregister.php file, but could use some guidance...
The topic has been locked.
Support Specialist
12 years 1 week ago #21134 by alzander
Replied by alzander on topic Google Analytics tracking
JW,
Sorry for the delayed response. Since Google's tracking is all Javascript based, most of what you'll want to do is 'on page', not necessary in the controllers or other areas which are mostly PHP based to get the page setup. It is possible to do some stuff in there, but may not be the most efficient.

Assuming you're tracking users through a funnel with GA, you have tracking setup on a few different pages of your site. That makes things easier as you (possibly) could just add the tracking code to whatever page the user is redirected to after registration/login. If you're using the redirection settings of JLinked to redirect to a specific menu item after registration, that should make it pretty easy. Simply put the code on that page. If the user hasn't gone through the funnel correctly, it won't trigger (which is good if any old user goes to that destination page).

The other option is to create a special "Thanks for Registering" page on your site and redirect LinkedIn users to that page after registering. Just throw the GA code on that page/article.

Those are the 'easy' solutions. If that's not what you're looking for though, let me know how your redirections are setup and let me know if you're doing funnels or just setting things up more simply as "User went to page 'x'" only, or any other information you have about your goals.

Thanks,
Alex
The topic has been locked.
Active Subscriptions:

None
12 years 1 week ago #21224 by jwhelan
Replied by jwhelan on topic Google Analytics tracking
Thanks Alex - some good ideas there.

The event that I really want to track is the when the "LinkedIn profile successfully connected." message appears. For me that represents a proper user conversion. I believe it is triggered in the controllers/loginregister.php file and ideally would like to echo some javascript to the browser at the same time. I'm not actually a programmer, so I'm picking my way slowly through the code trying to figure out exactly what is going on. Sorry for bothering you with this stuff. And, thanks for your help.
The topic has been locked.
Support Specialist
12 years 1 week ago #21248 by alzander
Replied by alzander on topic Google Analytics tracking
jwhelan,
Thanks for the further explanation. Normally, doing Javascript inside PHP is very difficult. The PHP code can do redirects and other things that don't print to the screen (or actively erase what's previously been echoed out). However, I just did some testing and found something that might work just great for you, and it's simple too!

Since you basically want to track whenever that string is displayed, just edit the string and put the text in there :) Edit the file /libraries/en_GB/en-GB.com_jlinked.ini. Find the string:
COM_JLINKED_MAP_USER_SUCCESS="LinkedIn profile successfully connected."
And update it to:
COM_JLINKED_MAP_USER_SUCCESS="LinkedIn profile successfully connected.<script type='text/javascript'>ga.track('blah');</script>"
The Google track code isn't correct, I just made that up. However, I tested doing that with some other Javascript and it seemed to work fine. Please make sure that you do *not* use double-quotes, only single quotes. Other than that, you should be good!

The other benefit of this is that, since it's in a language file, you're not changing the main component.. so you don't need to remember some obscure file you once edited.

Hope that helps, but definitely keep us posted. Never thought about doing JS in a language string, and pretty surprised/happy to see it works!

Alex
The topic has been locked.
Active Subscriptions:

None
12 years 1 week ago #21249 by jwhelan
Replied by jwhelan on topic Google Analytics tracking
Thanks again Alex. That was a very creative approach to solving the problem. I'll let you know how it works out.

-JW
The topic has been locked.
Support Specialist
12 years 1 week ago #21260 by alzander
Replied by alzander on topic Google Analytics tracking
Definitely let us know. Always like the easier solutions over the more complex ones :D

Thanks, and good luck,
Alex
The topic has been locked.
Active Subscriptions:

None
12 years 1 week ago #21302 by jwhelan
Replied by jwhelan on topic Google Analytics tracking
Alex:

Here's the code I use in the language file. It works perfectly:

COM_JLINKED_MAP_USER_SUCCESS="LinkedIn profile successfully connected.<script type='text/javascript'>_gaq.push();</script>"

It's pretty cool that the language file can be used for this.

-JW
The topic has been locked.
Active Subscriptions:

None
12 years 1 week ago #21303 by jwhelan
Replied by jwhelan on topic Google Analytics tracking
And the same technique works in any of the Joomla langauge .po files too. Probably not great coding methodology, but it works...
The topic has been locked.
Support Specialist
12 years 1 week ago #21310 by alzander
Replied by alzander on topic Google Analytics tracking
Yeah, I'm not going to recommend you do that for everything.. and there's no way we'd ever include that within our extension.. but it does avoid a lot of issues and (relatively cleanly) keep your change outside of our code.. which makes upgrading easier later. I wouldn't say it's bad on your end to do at all, and glad to hear it works. Had never tried that before, so was pleasantly surprised when it worked for me to test it out for ya.

On a side note, what's a Joomla language .po file? Not sure I'm familiar with that actually.

Either way, best of luck, and let us know if there's anything else you need!
Alex
The topic has been locked.