Tracking Traffic from Press Releases in Google Analytics

You are working on your site’s SEO by publishing press releases and you wish to track traffic to your site from those press releases.  You are not adding source campaign parameters (and therefore no campaign parameters at all) to your links because you are not sure which sites will pick up your press release.

Sounds familiar, doesn’t it?

In Google Analytics, you noticed that links from press releases are tracked as:

  • Source =,, or
  • Medium = referral
  • Campaign = (not set)

I am sure you are not satisfied with this basic level of tracking because it does not tell you much, especially if you wish to track across different campaigns and mediums.

The following example makes more sense and will help you evaluate and analyze your campaigns.

  • Source =
  • Medium = press_release
  • Campaign = hurricane_katrina

To overcome this challenge of tagging links from unknown sources, I came up with the following trick.


  • Add a parameter on all links to your site that are in the press release. (example:
  • On the target page ), check the value of the “id” parameter.
  • If the “id” parameter equals “1”, replace the parameter in the URL with the following utm parameters (utm_source, utm_medium and utm_campaign) before the call to pageTracker.
  • If the “id” parameter does not equal 1, call the pageTracker function normally.

View the entire code segment.

Let us explore the code, section by section:

This portion of the code will return the value of the “id” parameter from the URL and assign it to the “parameter” variable.

If the page url contains the “id” parameter and its value is 1, then the url will be updated with the utm parameters.

Link URL


* Notice that we did not use window.location.href function because this function will re load the page with the new URL, which is not what we want to happen. We just want to update the URL, without affecting the visitor experience, in order for the Google Analytics tracking code to attribute the visit in a certain way.

How to get the value of the utm_source (referral site)?

This portion of the code is responsible of assigning the URL of the referral site to the variable scrPage. The “getDomain” function parses only the domain name ( out of the long url string (

The last piece of code that needs to be added is the setAllowAnchor command, which allows the # sign to be used as a query string delimiter instead of the question mark (?).

We used # in the press release link instead of ? for SEO reasons, but you could use ? in the original link and still use the above method.

Alright, now it is time to use our friend Advanced Segments to track our press release visitors, measure their engagement, and analyze their behavior.

Now we can really analyze! :)

31 thoughts on “Tracking Traffic from Press Releases in Google Analytics”

  1. Excellent post and great use of the hash code to improve tracking without interfering with the user experience.

    I had one minor question for this line:

    “The last piece of code that needs to be added is the setAllowAnchor command, which allows the # sign to be used as a query string delimiter instead of the question mark (?). This part of the trick is sort of optional. We include it for thoroughness and because using # in incoming links instead of ? is for SEO reasons.”

    It seems like the fact that using ? instead of # would require you to reload the page is a big enough deal that setAllowAnchor wouldn’t really be optional.

  2. Great post and great method. Using the anchor is a good idea anytime you’re creating tracking URL’s that could potentially be published on another site. It prevents the negative impact to SEO and user confusion of parameter-based tracking codes. Nice work!


  3. Hi Jeremy,

    Thank you for your comment.
    What we wrote near the end about the optional part isn’t quite what we meant so I updated the blog post.
    setAllowAnchor is definitely required.
    # in the original link is optional since you could use ? to begin your parameter list and still use the above method.

  4. Hi Caleb,

    Thank you for posting.
    I got the idea from you at the GAAC summit and was waiting to make good use of it.
    I have always felt that good web analytics and good SEO can and should go hand in hand.

  5. Is it possible to manually specify the campaign and so on in the actual HTML code?

    i.e. let’s say I know that all visitors who end up at a given url should be part of the same campaign, so should always be the ‘bleh’ campaign.

    is there a way in that page’s source code that I can do:

    pagetracker._setCampaign(“bleh”) or even something like trackPageview(/bleh.html?utm_Camp=bleh) or something to that effect?


  6. Hi Phil,

    Yes that is very much possible.
    We intended the above technique to be deployed on a case-by-case basis.

    So the actual code to get a campaign name of bleh and replace what was in the post might be:

    if (parameter == ‘1’)
    window.location.hash = “utm_source=”+srcPage+”

  7. In relation to use of tracking URLs on other sites, Caleb states above “It prevents the negative impact to SEO and user confusion of parameter-based tracking codes”.

    I have a situation where we write articles to promote our company/products and submit to a content syndication outfit. Editors of pubs, papers, blogs, etc. can then use these submitted articles for their use instead of writing content on their own. Since the articles we write get picked up all over the place (not a single referrer), I am using utm/campaign URLs to determine how many times we are receiving visits/pageviews from this syndication network as well as goal completions. Does this actually have a negative impact on SEO or is it neutral?

  8. The potential (not guaranteed) SEO problem is that you have the same content available under multiple URLs.
    As you know, this could be a problem and it is preferred to always have one and only one URL for every page.

    And sometimes the URLs with campaign parameters are returned in search results, which places the visit in the wrong medium/source/campaign buckets.

    So you use # instead of ? (along with an update to the GATC) and you can have the best of both SEO and Analytics worlds.

  9. Hi Rehan thanks for the fantastic advice,
    I’ve never seen your blog before fantastic (where’s your twitter link!)

    I have the problem in reverse!

    Accurately measuring exits off site via 3rd party links in Analytics.

    I have a scenario where external links all over our Word Press site. I would like to capture data in Google Analytics only when a user clicks one of our external links:

    A) Which page(s) did they click the exit from (Filter for that)
    B) The exact text of the link (Filter filter for that)
    C) The html address of the exit link

    I’m sure there is an elegant-automated way to do this.
    With my limited understanding page exits (Top Exit Pages?)

    I know “Last Page” measurement is impossible to measure! (So I won’t whine about that) – but being able to plot the exit links, that would be something!

    I am aware you can use Event Tags. But this would mean you would have to manually tag every 3rd party link on a site with event tags! This would become impossible & onerous. And I think there is a maximum number of events Google Analytics will track per unique visitor (500?) – So what do you do for your articles with the the top 100 site links!

    Even worse if you don’t tag those external links properly, Google treats this as a page bounce! The way I see it if somebody bothered to click a link you provided on your site, that’s not a bounce. Its engagement!

    Some one suggested using jump pages-but I’m worried about the user being pissed off by the delay, and the page bloat on the site..

    Is there an elegant way to do this with a PHP / WordPress solution.


  10. Hi Stan,

    So basically you want to know points A, B, and C when someone clicks on an exit link.
    But manually tagging all the exit links would be a royal pain.

    Some custom javascript will do exactly what you want.
    We have done similar auto-tagging of external links with javascript but to collect different data (for example, D, E, and F).

  11. Hi Rehan and Allaedin

    Great post. I almost invented the same method but I missed the part with window.location.HASH, which is a really beautyfull solution.

    Tip: The exact same technique can be used to track traffic from search engines to specific “campaign pages” (read: SEO pages). You would then use paramateres like: “utm_source=google
    &utm_medium=organic&utm_campaign=campaignpages&utm_term=” + GetTerm();

    Best regards, Jesper

  12. RE: Nov 4th reply.
    Thanks Rehan

    Yep I think you understand what I’m looking for…
    If you could point me in the right direction, I would be in your debt. Short of spending a year learning PHP myself. Is this a complex solution? Your reply seemed to be cut off..

    Or solution 2 – keep grovelling before our IT guy. (He’ll schedule it in….which means never) :-)


  13. Hi Stan,

    Sorry for the short reply.
    Trying to balance knowledge sharing with chargeable work. :)

    The way I would approach it would be with Javascript.
    There might be a way to do it with PHP but I am more familiar with Javascript for click events.

    There is existing javascript out there that can be customized to place onClick events on every exit link.
    As far as I can tell, all three items you want are available with javascript.
    So basically you would customize the onClick event for exit links to get the information you need and send it off.

    Hope that makes sense.

  14. Thanks so much for sharing Rehan,

    I think I know the direction I have to go now, You got to pay to play!
    Thanks for taking the time, to respond.

    Have a great day.

  15. I am just wondering if this methodology will also allow tracking of where (for example) someone who clicks through from CNN goes after they hit the News Release page.

    Great article!

  16. Hi Les,

    Yes it does, if you have links on the press release to your site..

    Let’s say your press release was picked by or, this hack allows you to track all visits to your site from links in the press release. All activities after that inside your site by the such visitors will be credited to:
    Source = or
    Medium = press_release

  17. Thank to very much for sharing this post with us.
    I Read this post.
    Press release is a way to link building.

  18. Do you use the meta headings on blog posts then? I heard told
    me to stop using them a while a go as they are no use anymore
    Added a share on my Facebook, hope thats okay

Leave a Reply

Your email address will not be published. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">