Last Updated: 01 Nov 2023

   |   

Author: 114.119.148.47

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
marketing-tech:google-analytics:old-campaign-data-appearing-in-new-reports [Nov 1, 2012 07:44 AM]
dordal
marketing-tech:google-analytics:old-campaign-data-appearing-in-new-reports [Nov 1, 2023 10:25 AM]
114.119.148.47 old revision restored (Oct 25, 2023 01:58 PM)
Line 1: Line 1:
 += Google Analytics: Old Campaign Data Appearing in New Reports =
  
 +If you've used Google Analytics for a while, and run a number of different campaigns (adwords, email, or anything you track with the ''utm_campaign'' variable), you may notice that you get really old campaign data showing up in new reports. For example, I'm still getting a few visits from a campaign that I stopped nearly four months ago! I //know// the campaign isn't running anywhere anymore, so how come new visits with that campaign source are still showing up in my analytics today?
 +
 +It has to do with the way the ''_utmz'' cookie stores campaign data. Basically, when a visitor comes into your website via a campaign, Google Analytics stores the information on that campaign in the ''_utmz'' cookie. By default, [[http://code.google.com/apis/analytics/docs/concepts/gaConceptsCookies.html#cookiesSet|that cookie has an expiration time of six months]]. Now, if the user comes into the website later via a //different// campaign, that new campaign is stored in the ''_utmz'' cookie, overwriting the old one.  However, if the user comes back via direct navigation, **no data in the cookie is changed**, but the expiration date on the cookie is updated (reset for another six months) and the visit is attributed to the campaign recorded in the cookie.
 +
 +If you think about it for a minute, this is what you'd want to have happen. If a user comes to your website via a campaign today, and then comes back tomorrow and buys something, you'd want the source of the sale to be attributed to your campaign, and not ''(direct)''
 +
 +The trick is the six month expiration time. In my case, I had a few users that came in via my original campaign, and then kept coming back every few weeks for //months// (via direct navigation). Every single time they came back, the ''_utmz'' cookie provided data on that original campaign and the expiration on ''_utmz'' was updated for another six months. Their new visits were recorded as being from that campaign, even though the campaign had been gone for a long time.
 +
 +The solution? Just [[http://code.google.com/apis/analytics/docs/gaJS/gaJSApiCampaignTracking.html#_gat.GA_Tracker_._setCampaignCookieTimeout|set the campaign cookie timeout]] to something shorter. You do that with the following code in your GA javascript:
 +<code javascript>
 +// set the timeout to 30 days (2592000 seconds); same as the adwords cookie
 +_gaq.push(['_setCampaignCookieTimeout', 2592000]);
 +</code>
 +
 +Now your campaign data will expire after a month, so if the user comes back after that they'll be attributed with a source of ''(direct)''.
 +
 +//NOTE: Technically, this scheme isn't completely infallible, as the expiration on the cookie is reset with each pageview. So if a user came back to your site every 29 days, they could theoretically persist the ''_utmz'' cookie forever. You could set the timeout shorter, but you start running the risk of losing valuable conversion data. Ultimately, it becomes a judgement call. //