Knowledge |

Measuring Content Engagement in Google Analytics – Part 2: Social Share Click Tracking

Content Engagement Metrics Toolkit for Marketers:

  1. Article Completion Rate 
  2. Social Sharing
  3. Social Exits – Coming Soon
  4. Video Engagement – Coming Soon
  5. Content Copying – Coming Soon
  6. Page Printing – Coming Soon

Social Share Click Tracking

Difficulty: 3/5

Requirements: Google Analytics, Google Tag Manager

In this series of posts, we’re exploring how we can better measure when users are engaging with content. Google Analytics is inherently bad at tracking micro interactions on webpages. This lack of engagement tracking means that things like Bounce Rates and Avg. Time on Page are painfully inaccurate. In my last post, I walkthrough how to make those metrics work for you. Check it out here.

Note: You don’t need to follow the proceeding steps to do this one.

In this post we’ll be looking at how we track clicks and shares of your content to social media using Google Tag Manager, Events, Custom Metrics, Calculated and Goals.

Like a lot of sites, the use of “Share to: X” widgets is commonplace. But who’s actually tracking interactions with these? I like to think that if somebody is willing to share content on social media or by email, they feel it’s worth sharing. It’s self-propelled influence marketing and that’s the best kind because it’s free. So let’s make a count how many people are clicking these buttons and record it as something we called a “micro goal”. Micro goals are indirectly linked to Macro goals but show us that there is interest in the content, product or whatever is on the page.

For us, we’re not directly selling products on our site – you can’t add anything to cart so measuring micro interactions is important. There are two types of social clicks we want to track:

  • Social Exits
  • Social Shares

The following article focuses on Social Shares.

Tracking Social Shares

A social share click is simply when a user clicks on a button much like the one highlighted above and it takes them to a social network where they can then share the content. Let’s track those clicks and add in some extra fairy dust to calculate our Social Share Rates as percentages.

Create yourself a new workspace within your Google Tag Manager container

This should always be your first step when working in GTM as it prevents people overwriting or deploying your work early!

New Variable: Regex Lookup – Click URL – Social Share Identifier

Be sensible with naming variables because once you have a couple of hundred, you’ll kick yourself for calling everything “my clickurl var sharing version 5a” or something along those lines.

The purpose of this Regex Lookup table will be to identify the Social Network OR Email the clicked URL contained. This will vary depending on your setup but I suggest right clicking a share button and seeing what the URL looks like.

We actually use a plugin which means our setup may be different to yours but here’s the URL for facebook as an example:

https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.3whitehats.com%2Fknowledge%2Feffectively-measure-content-engagement-in-google-analytics-part-one%2F&linkname=Effectively%20Measure%20Content%20Engagement%20in%20Google%20Analytics%20%E2%80%93%20Part%201&linknote=

Although it’s a big URL, we can see a pattern here – the network is shown within the second page path so let’s use that. After clicking through all my share buttons to get their URLs I have the following:

  • https://www.addtoany.com/add_to/facebook
  • https://www.addtoany.com/add_to/twitter
  • https://www.addtoany.com/add_to/linkedin
  • https://www.addtoany.com/add_to/email

So now I have these 4 urls, I can add them into my Regex Lookup Table Variable like so:

What I’ve done here is tell the lookup table to look at the Click URL variable and if a partial match is found against any of these links, return the value in the right hand column of the table. To enable partial matching within a Regex Lookup Table, untick “Full Matches Only” and also “Enable Capture Group and Replace Functionality”. The latter shouldn’t affect this variable but unless I want to use that functionality, I shut it off. Save the variable.

New Trigger: Link Click – Social Share Click

Next we need to get a trigger ready to fire an event when a share link is clicked

This is a simple trigger which will fire on any click WHEN the Regex Lookup Table variable has a value.

New Tag: GA – Event – Social Share

Lastly, let’s create a GA Event driven by our new variable and trigger to identify share clicks across the site.

With this event, I want to categorise it under Engagement so my Events list is somewhat tidy. I also don’t need to load a lot of information into this event so I can afford to sub categorise it in this way. Note how I have passed the output of the regex lookup table into the Label field. This will identify which social share network was clicked.

So with my new changes in GTM ready and my container in Preview Mode, I can jump onto the site and test some links. As you can see in the screenshot below, I clicked on the Facebook share icon which opened up a new window to process the action. And as expected, the new Event I created is now firing with the network identified as Facebook.

If you have a look at Realtime Events in GA you’ll also see the Event pop up.

Optional: Adding a Custom Metric to Google Analytics

If you want to calculate share rates for your posts, you could add in a new metric with the GTM event so that each click increments a new custom metric within Google Analytics.

To do this, we need to head into Google Analytics > Admin > Custom Definitions > Custom Metrics and add a new Custom Metric

Click on + New Custom Metric

Name your metric Social Share Clicks and set Scope to Hit and Formatting Type to Integer. Click Create and then Done on the next screen to return to your Custom Metric list.

In my case, the Index number for my new Metric is 4. Yours might be different, just remember it for the next step.

Head back into GTM where you were working and open the new Event you created and click the tickbox “Enable overriding settings in this tag”. Then open up “More Settings” and click on “Custom Metrics”. This is where we will pass the new Custom Metric a value each time the event fires. As explained earlier, my index number is 4 but yours may differ so double check what it is in Google Analytics under Custom Metrics. The metric value needs to be set as 1.

Once done, save this tag. If you’re happy your Event is firing when it should be, deploy your workspace updates so they’re live.

Optional: Add a Calculated Metric in Google Analytics

To be able to calculate a share rate in GA, we need to utilise the Calculated Metrics functionality which can be found at View level within the GA Admin settings for your account.

Click + New Calculated Metric and configure as shown below. When you enter the formula, ignore adding the curly braces and instead start typing the name of the Metrics you need. In this case, we want to know the number of Social Share Clicks divided by the total number of pageviews and display it as a percentage.

Once that’s all configured as above, click Create to save the Calculated Metric.

Reporting on your new data

Now we’ve got everything up and running and our new metrics in place, we can build a mini report to check how much posts are being shared.

Head into the Customization Menu > Custom Reports > + New Custom Report

It’s a simple setup and should give us an indication of how many people are using the share function on our content pages. I’ve locked this report down to only show data from our Knowledge Base using a Page filter. The main reason for this being that the social share functionality only appears on blog posts so this excludes lots of page rows showing 0 as a value where it’s impossible for it to be anything else. And that’s how you track social shares in Google Analytics using Google Tag Manager. Drop a common below with any questions you may have.

Part 3 will explain how to track visits from a website to social networks.