Failed to build swatch for thumbnail on page Marketo and Google Analytics Tracking for AddThis Sharing Buttons

Marketo and Google Analytics Tracking for AddThis Sharing Buttons

Marketo sharing buttons are terrible. They are styled poorly, they lack a variety of networks, and don’t cater to their audiences. It’s for these reasons that I started using AddThis for sharing functionality on Marketo landing pages. I find it very ironic since Oracle has acquired AddThis.

Here is how I integrated AddThis sharing buttons with Marketo so that I could measure sharing metrics in both Marketo and Google Analytics using munchkin link click tracking and google analytics events.

The Code

Explanation

Below I’ll go through things line-by-line for those that might be confused or can’t follow the comments.

Line 5

Check if AddThis exists. If you have cut, copied, and pasted the sharing buttons and script anywhere on your site the AddThis will exist.

Line 6

If it does, add an event listener for when the user shares (see AddThis docs).

Line 15

Make sure it’s the share event (not really necessary, but too be safe if we decide to use this code for other event related stuff). In the docs you can just listen for all events and add all of the event specific code in here.

Line 18

Obviously a prerequisite to this is having Google Analytics code on your site. After you are confident you do, record a custom metric for total shares in Google Analytics (see google docs). You will need to have a custom metrics set up before you implement this part of the code, and you will have to make sure that the metric part of the code matches with the metrics you’ve created. For every person this will be different depending on your GA setup.

Line 21

I have Google Analytics measuring shares for every single network that matters to the companies I work with, however this might be different for you. On this line there is a switch that takes the AddThiss button that was clicked and matches it with the metric that you want to measure in GA. You can log “evt.data.service” in the console if you need to find the network name.

Line 40

Here I am doing some general event tracking populating the event with the AddThis service. (see google docs)

Line 43

Here I am doing some built in Google Analytics social event tracking (see google docs)

Line 46

Here I am crafting a unique link based on the page the user is on, the service they shared on, and the string “addthis”. Note, this isn’t actually a link that the user is clicking, it’s a fabricated link that allows you to craft a “clicked link” filter in Marketo for smart lists and reporting purposes. Works like a charm. The order of the addthis / service portion matters because of how you might pull smart lists differently (all networks vs specific networks).

The Results

You get a remarkable amount of data with this seemingly simple snippet of code.

Google Analytics

In Google analytics you’ll be able to see how many people shared your pages on a network-by-network basis on for your selected networks, as well as see sharing event stats for EVERY network.

Marketo

In marketo you will be able to pull smart lists to see who has shared on any network. You can created custom fields to tracking sharing stats, and you can report on these numbers as such. Best of all, you aren’t limited to just Twitter, Facebook, and LinkedIn. It’s every damn network that AddThis has in their arsenal. In this way, if you get great publicity on reddit or Dzone… you can measure it.


Subscribe for More!


I send out a monthly newsletter on various topics.

Take a moment to enter your details, and you can select the news you would like to have delivered to your inbox!