Skip to content

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 }
//add our hook with higher-than-default priority
add_action('wp_footer', 'bb_ga_social_footer', 20)
* Require WP to load jQuery if not already loaded
* h/t @Ramoonus
function bb_ga_social_enqueue() {
//add hook to enqueue jQuery on load
add_action('init', 'bb_ga_social_enqueue');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment