How to Track Twitter Traffic in Google Analytics

183
5073
Downloads
959.24 Kb

This article is a short how-to guide about connecting your Twitter account to Google Analytics and tracking Twitter traffic.


Table of contents

Long story short: although Twitter is a social network website, you can’t connect your Twitter page directly to Google Analytics. Twitter just doesn’t offer this opportunity. But since you’re reading this, you probably want to figure out how to track your Twitter statistics all the same. So let’s look for a workaround.

If you want to see how well your Twitter account is performing, you can go to https://analytics.twitter.com.

Not only does Twitter’s official analytics platform provide useful information on how popular and engaging your tweets are, it also allows you to export this data for further processing. If you want to see how well Twitter performs for your site, Google Analytics may bring you the necessary insights.

How to track traffic from Twitter in Google Analytics

The good news is that Google Analytics tracks traffic from Twitter by default. Maybe this data will be enough for you to take further action.

  1. Open Google Analytics. ​
  2. Go to Acquisition —> All Traffic —> Source/Medium.
Acquisition Report in GA

Your source (where your visitors come from) should be twitter.com or t.co, and your medium should be referral (meaning visitors came to your site via a link on another site). Pick the relevant options in the list to find more information on Twitter traffic.

You can also find this data in Acquisition —> Social.

If you use promoted tweets, Google Analytics can help you measure their effectiveness as well. For that, you’ll first need to customize the links you’re using in your ads with campaign tags.

The easiest way to do that is with the Google Analytics URL Builder.

URL campaign builder

Here’s how you can fill out the fields there:

After that, you can go back to your Acquisition —> All Traffic —> Source/Medium report and notice two kinds of traffic:

  1. Twitter.com / referral — This is your organic Twitter traffic.
  2. Twitter.com / social — This is Twitter traffic from your paid ads.
Acquisition —> All Traffic —> Source/Medium report

Click the last option to study your traffic from paid promotions on Twitter and find insights. But for deeper analysis you need to import the cost data.

Need more options?

Automatically import your Twitter campaign data 
to Google Analytics with OWOX BI!

Twitter to Google Analytics pipeline

OWOX BI is designed to help you get much more from your data by consolidating it from separate systems.

For instance, with OWOX BI, it takes only seconds to import and analyze cost, click, and impression data from your Twitter campaigns in Google Analytics. Merge it with cost and CRM data and you’ll have the most comprehensive base for your analysis.

TRY FOR FREE

How to track Twitter interactions on your site with Google Analytics

If you have Twitter-related buttons on your site, you can track and analyze their performance with Google Analytics.

There are two Twitter buttons you can place on your site via publish.twitter.com:

Note: Twitter also offers variations of the Share button in the form of Mention and Hashtag buttons. These act just like the Share button, only instead of a predefined link they start with a mention of an account or a hashtag. The instructions below can be used to track them as well.

To analyze the performance of the Follow and Share buttons, you’ll need to go through a series of steps that you might want to assign to your webmaster. Here they are.

Overview: The goal of the following actions is to create a Twitter button click listener via Google Tag Manager to catch your users’ interactions and pass them to Google Analytics.

  1. Create a Twitter listener tag in Google Tag Manager.​
    Tag type: Custom HTML
    Tag title: cHTML Twitter Listener
  2. Insert this code into the HTML section of the window.
    
<script>
if (typeof twttr !== 'undefined') {
 twttr.ready(function (twttr) {
 twttr.events.bind('tweet', tweetIntentToAnalytics);
 twttr.events.bind('follow', followIntentToAnalytics);
 });
}
function clickEventToAnalytics() {
 dataLayer.push({
 'event': 'socialInteraction',
 'socialNetwork': 'Twitter',
 'socialAction': 'click',
 'socialTarget': window.location.href
 });
}
function tweetIntentToAnalytics() {
 dataLayer.push({
 'event': 'socialInteraction',
 'socialNetwork': 'Twitter',
 'socialAction': 'tweet',
 'socialTarget': window.location.href
 });
}
function followIntentToAnalytics() {
 dataLayer.push({
 'event': 'socialInteraction',
 'socialNetwork': 'Twitter',
 'socialAction': 'follow',
 'socialTarget': window.location.href
 });
}
</script>
    
  1. Click on the Triggering block section and select All Pages.
Twitter Listener configuration
  1. Check if the new tag is working: click Preview in Google Tag Manager, navigate to the page of your site where the Tweet button is installed, and see if clicking it fires your socialInteraction tag in the console.
  2. Create a trigger that will recognize a socialInteraction event.
    In Google Tag Manager, proceed to Triggers and create a new trigger with the following parameters:

Trigger type: socialInteraction
Custom Event: This trigger fires on
Event name: All Custom Events​

Tag creation in GTM
  1. Now you need to create three variables in order for Google Analytics to learn what kind of action the click has triggered, what social media channel is involved, and what will happen as a result of the click. ​

Open the Variables window in Google Tag Manager and create the following three variables with these parameters:


Variable Configuration
  1. Create a Google Analytics tag.​This tag will fire after the following sequence of actions:
  • Your custom HTML Twitter listener tag has fired
  • The visitor has clicked the Tweet button
  • The Twitter listener has spotted the click and created a socialInteraction data layer as a trigger
  • The trigger has launched a Google Analytics tag

To do this, create a new tag in Google Tag Manager.​ 

Choose the Google Analytics — Universal Analytics tag type. Select Track Type:
  • If you choose Event, you’ll see the necessary data in Google Analytics in Behavior —> Events. The click data will be seen both in real-time and in reports. 
  • If you choose Social, you’ll see the click data in Acquisition —> Social —> Plugins. The collected data won’t be seen in real-time and will be available only after 24 to 48 hours.​
Define social tracking parameters:
  • Network: socialNetwork
  • Action: socialAction
  • Action Target: socialTarget

Select socialInteraction as the firing trigger.

Finally, you’re done. 

Now you can track the performance of your Tweet buttons in Google Analytics via Behavior —-> Events or Acquisition —> Social —> Plugins depending on the Track Type you’ve chosen in the Google Analytics tag.

How to track Twitter widget and embedded tweet performance with Google Analytics

Unfortunately, you can’t do this right now. 

When you embed a tweet or a Twitter widget in your site, you basically insert a frame with dynamic content you have no control over. So the activity inside of it (like button presses) can’t be tracked by Google Analytics.

The best way to merge Twitter data and Google Analytics data

Although you can’t connect your Twitter page to Google Analytics, whatever your goal is, it probably can be achieved in another way. If your problem has not been covered above, you can look for third-party tools that merge Twitter data and Google Analytics insights.

Consider OWOX BI Pipeline, which we mentioned above. OWOX BI makes a reliable connection with a number of advertising services and your data warehouse to help your analysts get more insightful reports based on the comprehensive data, and bring more profit for your business.

Start a free trial

If you still have questions, please let us know in the comments below. Also, follow us on Twitter and we’ll tweet you back!

Used tools

You might also like