Upcoming LunaMetrics Seminars
Pittsburgh, Jan 12-16 Boston, Jan 12-16 New York City, Jan 26-30 Denver, Feb 9-13

32 Responses to “A Google Analytics Social Engagement Tracking WordPress Plugin”

Blair says:

Hi Sharif,

With the new Google Analytics Traffic Sources > Social reports, is it still necessary to add the code used with this plugin?

Sayf Sharif Sayf Sharif says:

Well, some of the features of the new reports were there all along, they’re just more specifically called out. So you don’t need to add this tracking code to see when someone visits you FROM Facebook for instance. However if you want to see when people actually click on a share or social button, you’ll still need to add this code (other than for Google+ which is the only automatic one). Without a TrackSocial call, you won’t see whether they ‘engaged’.

Olivier says:

I would strongly encourage you to publish it on the WordPress plugin repository. This would give additionnal visibility to your business :)

Josh says:

2nd vote for putting it on the WordPress plugin repository. That way it could be installed entirely through the dashboard.

Sayf Sharif Sayf Sharif says:

It’s a great idea. I’d thought about it initially but time was of the essence to get the post up. Of course since then I’ve been busy with other things, however I will put this on my to do list to get it up, either in this form, or in the other more full featured but highly secret wordpress google analytics plugin i’m working on….

Mitch Neff says:

Quick question – does this plug-in write the js snippets to the social plug-ins or simply act as middleware? Basically, if I were to install and then de-activate/uninstall the plug-in would the js code for social tracking remain persistently or disappear with the plug-in? I really like this approach. This makes things a lot simpler…

Sayf Sharif Sayf Sharif says:

Mitch basically here’s how it works, it’s brutally simple. Seriously brutally simple.

WordPress has different “hooks” which let you insert code at different spots on the page. We’re using two of them in the plugin. One to insert code of our choosing into the head of every page, and one to insert code into the body right before the tag on every page.

Then we’re basically just pasting in the general code for that page for the various plugins. The code per the previous social engagement tracking page that belongs in the head, we slap in the head, the stuff that goes in the body we slap in the body.

So if you deactivate it, the js code disappears from your pages. If you reactivate it, it will start showing up again.

It’s pretty much as basic a WordPress plugin as you can get, but when all the other social plugins seem to be missing this piece, we felt that it was better to just make a plugin that added the social tracking code, which would still allow you to do whatever you wanted with your social buttons (whether that’s hard coding them, or using digg digg, or whatever).

Olivier says:

If you put it on WP rep, please make sure that you use the same namespace, otherwise, early users won’t be notified about updates :)

Then if you want to integrate it with the GA tracking code, I would suggest you to load everything in async mode :)

Great work here! If you need some assistance to put the plugin on WP rep, feel free to drop me a mail, I have been through that already :)

Sayf Sharif Sayf Sharif says:

Thanks Olivier, if people keep nudging me to get it in the WP repository I may actually do it!

Jacob says:

Is this plug-in still available? When I try to download the .zip file I keep getting a 404 page.

Has the plug-in been moved to the WP repository? If so what is its name? I couldn’t find it when I searched for it.

Sayf Sharif Sayf Sharif says:

It’s not in the repository, i’m not sure what happened to the file on our servers however. it’s just gone, I need to confirm which is the latest file we have of it to put it back up in the correct spot.

Keith says:

Was excited to nab this plugin, then got a 404 :( Any chance it will be available again soon?

Rob says:

Great work, but it seems I can not download the file.

Can you please fix the link?

Sayf Sharif Sayf Sharif says:

Link is fixed. Sorry about that fellas. It disappeared from our staging and production servers mysteriously, and then I got distracted by a shiny object. But I found it and have reloaded the plugin and the link above should work fine again.

Sebastian says:

Giving this plugin a try right now. So far so good! The only test that doesn’t seem to be working is the Facebook interactions. Any idea why? Anyone else seeing this issue?

Thanks for taking the time to make this plugin!

Sebastian says:

Quick edit to my last post. Looks like LinkedIn isn’t working either. So far all I’m seeing under social plugin analytics are twitter and google plus. I only have facebook, twitter, linkedin & googleplus available, so 2/4 are working.

Sayf Sharif Sayf Sharif says:

Sebastian, I’ll take a look at the plugin and see if there have been some changes that need to be taken into account.

Sebastian says:

Tanks Sayf, I’ll check back to see if you found anything.

Appreciate the quick reply!

Sayf Sharif Sayf Sharif says:

Sebastian, for the linked in, it’s poor documentation on my part. The LinkedIn will only work if you add the function to the linked in share button as well as adding this code…

http://www.lunametrics.com/blog/2012/03/29/tracking-social-google-analytics/

Check out that link, which is the code this plugin was based on. Your share button for linked in should look something like this…

…With the data-onsuccess=”LinkedInShare” being key there to running the function pushing a track social for LinkedIn.

As far as Facebook I’m not sure. With the ga_social_tracking.js file which is included with this plugin, and the basic facebook scripts, it should be tracking. In my test environment it’s working. So I’m not sure. Are you using any other facebook scripts on the page which coudl be interfereing with the plugin?

Sebastian says:

Sayf, thanks for the quick reply once again. I have a feeling it may be the plugin I’m using for WordPress that’s causing the problem. My social “like”, “share” buttons are added to my site using the “Really Simple Share” plugin which adds the buttons to the bottom of each blog post.

Do you have a particular plugin you’re using to add the buttons or are you hard coding them in?

Still odd that my Facebook isn’t tracking though, not like the plugin can create a “like” button without using the same functionality everyone else uses when creating that button for Facebook.

Anyway, if you have any other answers for me, that’s awesome. If not, I still appreciate the time. Thank you very much.

Sayf Sharif Sayf Sharif says:

We’re just coding them in manually, per that previous post. I have the code we’re using essentially there.

is the like button showing up on the page and working, but simply not tracking, or is the button not showing up at all? if it’s not appearing, working, it could be a temporary thing with Facebook that isn’t delivering the code. I’m going to double check and confirm that Facebook hasn’t changed their code used here.

ian says:

Hi Sayf
Thanks for the article. My 8 yr old site and it’s .com/ pages had unique google analytics codes. I d like to keep that level of monitoring. Do u know how that would work now the sites been changed to a wordpress 20/11 site? Which folders are my different pages and posts in and where would I place each of the UA nos for each page?

Thanks for any insights,

Ian

Any help would be

Sayf Sharif Sayf Sharif says:

ian, i’m not totally clear on what you’re asking. If you’re asking in general where to put your google analytics tracking on a wordpress site, I recommend using the GA plugin by Yoast.

http://yoast.com/wordpress/google-analytics/

Jamil says:

Thank you for making this plugin code! I just installed it and clicked on a like button, but I don’t have much site traffic at this time, and am wondering how I can see if it is working correctly? Which section of Google Analytics should I see these like / share clicks? How long does it take to activate?

Sayf Sharif Sayf Sharif says:

I’d test it by putting it on a page, and then clicking on one of the social buttons and then watching GA real time. If you don’t have much traffic the hits should show up within 15 minutes within the standard reports. once you see the page hit that you did, look in social sources/actions and if you’re not seeing it there you’re probably not installed correctly.

Jamil says:

Thanks…that’s my problem. I don’t seem to have the actions section under the social traffic sources on GA.

Chris says:

Hi Sayf,

Great plugin. I just did the GA 201 and 301 course this week in Oakland and glad I came across this while scavenging the internet for an “easy button” to track social engagement.

I’m also using Google Analytics for WP by Yoast, along with a plugin called “Social Ring” on numerous WP sites I’m managing. Social ring seems to be gaining some popularity and traction.

This made it so easy to add the ga_social_tracking.js file and I trust the version you have in the plugin is the one to stick with… I came across a few variations while digging thru “Google Code” and figured the one Sayf is using, is probably the best option.

My two suggestions/requests:

1. Definitely get this sucker in the WP repository so we can get updates if/when they become available. I think a lot more people will be looking for this in the near future.

2. Write some more medieval javascript so this bad boy tracks “Pins” too!

Thanks!

Sayf Sharif Sayf Sharif says:

Chris,

I submitted it to WordPress but I formated it wrong and they rejected it. It’s on my list to do it right and get it in there, I promise.

A good reason is what you mention. If we ever can figure out a good way to track Pins. Right now we’re still dealing with a situation where Pinterest is not being particularly helpful in this regard. We’ve done some work arounds in the past, but none have worked 100%, and we’re really hoping the Pinterest API gets updated sometime soon to help us track these better. But if I ever do come up with a good clean way to add that on, I’ll be sure to post it here on the LunaMetrics blog.

Craig says:

Can anybody recommend a great social sharing plugin that is not your usual one with G+, FB, Twitter, LI, PIn etc. I am looking for something that works better than the stock std but integrates with facebook perhaps. Any ideas

Enterpr1se says:

Hi,

There’s a new Google Analytics trading javasceipt — analytics.js
https://developers.google.com/analytics/devguides/collection/analyticsjs/social-interactions
Is it possible to add this javascript support in the future?
Thanks so much

Hi

Thanks for this very handy plugin. It’d be super if Pintrest were added to your script – are there any plans to add such networks to your plugin?

Cheers,
Dave

Sayf Sharif Sayf Sharif says:

Last I checked Pinterest had certain restrictions. You can track link clicks generally out to pinterest, but not in the same sort of engaged way that say twitter or facebook does. Plus this code is seeing it’s age, and probably needs to be looked at again on our part, and as noted updated for new analytics.