Unleash the Power of Google Analytics (4): Tracking External Sources & Tagging URLS


Analytics series: Tracking external sources and tagging URLS

Google Analytics makes our lives very easy when it comes to dividing our traffic sources into easily manageable chunks. It automatically splits out non-paid search traffic and paid traffic from Adwords. It also tells us about keywords from all the search engines, plus referrals and direct traffic.

But what happens if you send out an email with links to your site, or run a PPC (pay per click) campaign on Yahoo or Bing? I’ll tell you what: it makes a big mess of all your data.

If you send an email, Analytics will track any clicks either a referral (from web-based clients like Hotmail) or as direct traffic (from Outlook or another offline email client). Your data will be totally skewed.

It gets worse. If you decide to run a PPC campaign anywhere other than on Google, Analytics will record the traffic as natural visits, and not paid visits. This is a real pain, and it ruins your data for natural traffic.

So what’s the solution?

As you know by now, the people at Google are very kind to us. They have provided us with a tool that can generate a tag to stick on the end of any URLs or links we might need to track. If you’re going to track lots of additional marketing activity, Google’s URL builder will become a very dear friend.

This is what it looks like.

Google URL Builder

And you can find it here:

All you need to do is follow the on-page instructions, add the details of where you’re sending the traffic, and then fill in (at least) the source, medium and campaign names. Then hit ‘generate’.

Google will now give you a URL. Any traffic that visits your site via this URL will be automatically assigned to the traffic source, medium and campaign name that you’ve specified.

Example 1 – email marketing.

This is the most common reason I use the URL builder tool. Whenever we send out marketing emails for our clients, we tag all of the links in the email back to the client’s site. This allows us to define the email as a separate traffic source in Analytics. Like so:

Source/ Medium in Analytics

Using the URL builder, we put a name for the email in the ‘Campaign Source’ box. You should give your email an easily recognisable name, so when you come to report on it later, there should be no confusion. With email campaigns, it’s sensible to add the send date, as above.

The ‘Campaign Medium’ should be defined as email. The only other required box is ‘Campaign Name’. If the email you’re tagging is part of a campaign, then you’ll want to use that campaign name. If it’s a one off, we tend to use the source name.

Example 2 – tracking a non-Google PPC campaign

Let’s say you want to track a Yahoo Search Marketing (PPC) campaign in Google Analytics. If you run the campaign without tagging it, Google will automatically record the visits as coming from Yahoo, but it will wrongly assume they are organic clicks.

To solve this problem, you need to tag your campaigns. Using the Google URL builder, you can specify the source as Yahoo and the medium as CPC (cost per click). You can then specify the campaign as “YSM-PPC-campaign” (or something similar). The URL builder will generate a tag that looks like this:

All you have to do is pop these tags on every ad URL in the campaign:


In this way Google won’t automatically define your CPC traffic as organic.

To gather even more detail, though, you should make use of the ‘Term’ box in the URL builder. This lets you to give every keyword its own tag, allowing you use Google Analytics to measure the success of every single one.

Top Tip: Tagging multiple keywords (some Excel knowledge needed)

Tagging every keyword in your Yahoo account might seem like a daunting task. However, using Excel, you can quickly and easily tag an account of any size. Export all of your campaigns into Excel, and sort the whole spreadsheet by component type. It will then group all of your keywords together. 

Next, use the URL Builder to create a tag that looks something like this (using this tag will work for any Google Analytics user, so feel free to copy and paste). You’ll see the utm_term and utm_campaign are blank.


Scroll across the header row of your downloaded Yahoo campaigns until you find “Keyword Custom URL” (normally column H). Insert a few blank columns next to this row (either side is fine).

In one blank column put the destination URL of the keyword. In the next column add the section of the tag that ends with utm__term=


In the column after that, put the last part of your tag:


Drag these tag columns all the way down so that every keyword has these empty tags in the column next to them. Now go back to your ‘Keyword Custom URL’ column and use Excel’s concatenate function to tie your columns together. You should tie in your destination URL, then the first part of the tag, then the keyword, then the second part of your tag, then the campaign column. (I’ve colour coded each part so you can see how the formula builds the tagged URL).

=concatenate(destination-urlfirst-tagkeyword-column, second-tag, campaign-column)

This should give you a fully tagged keyword level destination URL. It will look something like this:

Drag the concatenate formula down your list of keywords and it should automatically fill in all of your destination URLs.

Highlight the ‘Keyword Custom URL’ column, copy it, and then with the column still highlighted press ‘Paste special’ and choose ‘values’. This will overwrite your formula with your new, tagged URLs. 

After all that, you just have to delete the columns you inserted, and upload the changes. 

What else should I tag?

Everything that isn’t already sifted automatically by Google. This will help keep your Analytics accounts as tidy as possible, and allow you to access more information on the performance of your online activity, including elements such as banners, advertorial, or social media.

Subscribe to our blog and follow this Analytics series

More on this subject