Google Analytics source override precedence

Google Analytics keeps track of 5 campaign variables all this information goes into _utmz cookie. This cookie has the following format:
_utmz=1.1267299040.3.4.utmcsr=Source|utmccn=Campaign|utmcmd=Media|utmcct=Content|utmctr=Term
There are basically 4 types of origins:
  • Campaigns: this means the user clicked on an AdWords link or a link with campaign variables.
    • You can customized all 5 Campaign Variables
    • If this is an AdWords visit the cookie is slightly different, it has the gclid number. GA will pull the correct value for the 5 variables from AdWords provided the accounts are linked.
  • Organic: When the user clicks on a link from a Search engine (e.g. google, bing, yahoo!, etc)
    • Source: google/bing/yahoo/etc
    • Campaign: (organic)
    • Media: organic
    • Term: Searched keyword
  • Referral: When a user clicks on a link from another site.
    • Source: www.referral-site.com
    • Campaign: (referral)
    • Media: referral
    • Content: /path/from/clicked/link
  • Direct: When Google can’t determine a better origin it uses this one. Usually it means the user typed the address directly in the address bar. But it could mean the user bookmarked the link or still clicked this link in msn, or another desktop application.
    • Source: (direct)
    • Campaign: (direct)
    • Media: (none)
What happens if you change your source during a visit? What if it happens in a different visit?
It all depends, here are the basic rules for this precedence.

Returning Visitor

  • Direct never overrides
  • Campaign always overrides
  • Referral always overrides
  • Organic always overrides

Same Visit

  • Direct never overrides
  • Campaign always overrides
  • Referral never overrides
  • Organic always overrides

Extra

I created a graphic to illustrate precedence.

Update 1:

People complained about the graphic being insanely hard to read. Here are the rules that make the graphic. Looks simpler but the graphic took me too much time to just remove it now. Besides it makes the post look good.

  • Campaign, Organic and Referral source always override a previous source
  • Direct never overrides a previous source
  • If it’s inside the same session a referral source will never override previous source

Update 2:

You can also use the parameter utm_nooverride=1 in your URLs. If you use this parameter and already have a previous origin it  will never overrides the existing origin.

Update 3:

Google has changed the way it creates new visits. Note that the rules here still aplies. The only difference now is that any time a new source overwrites a previous source a new visit is created.

Before this change if the change occurred on the same visit a new visit would not be spawned but the new origin was still sent to analytics, this could cause sources with 0 visits in Google Analytics Reports.