Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Google Analytics Tracking of JetPack (Sharedaddy) Social Engagement
 * Plugin Name: Jetpack (Sharedaddy) Google Analytics Tracking
 * Description: Allows tracking of Facebook and Twitter shares in Google Analytics Social Tracking
 * Author: Benjamin J. Balter
 * Author URI:
 * Version: 0.1
 * Outputs javascript to document head
function bb_ga_social_footer() { ?>
    jQuery(document).ready(function($) {
        _gaq.push( ['_trackSocial', 'twitter', 'share',
        $(this).attr('href').substr(0,  $(this).attr('href').indexOf('?'))]);
        $('a.share-facebook').click( function() {
        _gaq.push( ['_trackSocial', 'faceboook', 'share',
        $(this).attr('href').substr(0, $(this).attr('href').indexOf('?'))]);
<?php }
// begin of my work
// end of my hard work
//add our hook with higher-than-default priority
add_action('wp_footer', 'bb_ga_social_footer', 20)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment