Title Image


Track Facebook Ad Campaigns in Google Analytics

I have been talking a lot recently about Facebook advertising and the benefits that it holds for online marketeers. One question that I have been seeing more and more about, however, is how to go about recording the performance of such adverts. With this in mind, I thought I would give you a quick step-by-step guide to setting up your Google Analytics to be able to track each of your individual Facebook ad campaigns.

tracking Facebook advertising in Google Analytics

From Facebook alone, you don’t get many statistics on the performance of your ads that are going to external webpages. Aside from the number of clicks that the advert has had, there is little information for you to go on. Not only this, but you have no idea on what the user did once they landed on your website because Google Analytics doesn’t differentiate the individual adverts, and even sometimes classes it as direct traffic. Not good. So here is a quick step-by-step that will enable Analytics to read the individual adverts and track the activity off the back of this:

Add a Few Extra Lines of Code to Your Google Analytics Tracking Script

The first step is quite simple. All you need to do is add a few extra lines of code to the tracking script that Google provided you with when you set up Analytics tracking on your website. The code you need to add is in bold (5 lines) in the example script below; make sure that you add this to all the pages on your website:

<script type="text/javascript">
var _gaq = _gaq || [];
 _gaq.push(['_setAccount', 'UA-XXXXXXX-X']);
_gaq.push(['_setCampSourceKey', 'utm_source']);
_gaq.push(['_setCampMediumKey', 'utm_medium']);
_gaq.push(['_setCampContentKey', 'utm_content']);
_gaq.push(['_setCampTermKey', 'utm_keyword']);
_gaq.push(['_setCampNameKey', 'utm_campaign']);
(function() {
 var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
 ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
 var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);

Build Your Custom URL via Google Analytics URL Builder

Now that you have added in the extra lines of code to your website tracking script, you can create a custom URL for the page that you want to run a Facebook advert to with custom tracking data. All you need to do is fill out the fields within the Google Analytics URL Builder Tool as follows:

Website URL: Enter the URL of the page that you are going to create an advert for.
Campaign Source: Facebook
Campaign Medium: CPC
Campaign Term: Leave this blank.
Campaign Content: Type the name of the individual advert here.
Campaign Name: Type the name of the Facebook ad campaign here.

Finally, press ‘Generate URL’ and then you will be presented with a custom URL that you need to use as the destination URL in your Facebook advert. Once this is done, you have successfully set up individual Facebook advert tracking within Google Analytics. Simple!

You can now see the different traffic coming through in the same way that you would see this via Adwords campaigns. Set up some conversion goals and you can create a way to really understand the performance of your adverts and improve them over time.

I hope this helps, and if you have any questions then just leave a comment below and I will do my best to answer it.

Qasim Majid About the author
Notify of
Newest Most Voted
Inline Feedbacks
View all comments

[…] Track Facebook Ad Campaigns in Google Analytics – Wow Internet Blog 1 Upvotes Discuss Flag Submitted 1 min ago Matthew Barby Analytics wowinternet.co.uk Comments […]

[…] have announced their intentions for a new set of features for Google Analytics, under the grand title of Universal Analytics. These are set to change and improve data collection, […]

Tap to Call