Social Media with Analytics.

How to add Social Media buttons into your website and track with analytics.

Off the back of reading another blog where the importance of Facebook Likes and the new Google +1 were discussed I decided it was time to implement full SEO integration on our site.  We’ve been doing it for clients for an age but with the new Google Panda Algorithm it is now ignored at your peril. Now I’m expecting that some of you are thinking – its easy, I just grabbed the code from X and stuck it in. That maybe the case but as far as my understanding extends this method adds google analytics tracking functionality.

This is my experience of implementing it as described on Yoast’s Social Buttons: Adding them to your site & Tracking them Post because as you can imagine it wasn’t straight forward and I found that a few steps were either skipped or lost in translation.

Before you start ensure you have all the open graph meta tags suitably placed into your page head. You can test this using the Facebook Lint Tool. You’ll also need to find your APP ID and to do this go to Facebook Developers

Above you will see I’m using the featured image function to link with the og:image. If you don’t already have this enabled you need to got to functions.php and add:

As you do this you also need to add the correct declarations to the page html tag.

Now my preference is to create a template snippet for the next section as it can be included in single blog posts, pages etc at will. You’ll also want to be able to move it to other projects in the future I’m sure. So I create a new file in my template folder called social.php and add the following code. You’ll want to change the Data-Via for Twitter to your twitter name.

 

 

 

 

 

 

Now you can add this to other pages in the theme using the following line. I use the Toolbox theme as the basis for all my templates so have included this line in the content-single.php file.

And that is it (I think!)

About CDB 360 Articles
Self-Employed Software Developer, Spark, Property Management, Hobby Forestry, Ex-Teacher, Engineering - Wood, Metal, Electrics & Computers. Outdoors - Walk, Cycle, Kitesurf,