Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1057517
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T17:52:52+00:00 2026-05-16T17:52:52+00:00

Does Google Analytics store the utm_source, utm_medium paramaters in a cookie or something similar

  • 0

Does Google Analytics store the utm_source, utm_medium paramaters in a cookie or something similar that I can access on my own site using PHP? – OR – does anyone have an example of code I could use to identify a traffic source ie. PPC, Natural etc.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T17:52:53+00:00Added an answer on May 16, 2026 at 5:52 pm

    Yes, Google stores this information in a cookie; specifically, the __utmz cookie.

    You can write a piece of JavaScript to read the cookies that GA stores in the browser. This information is stored in the __utmz cookie. For example, if a link contained all 5 possible utm variables, the cookie would look something like this (I’ve substituted the capitalized names for the values, so SOURCE is the value for utm_source:

         43838368.1283957505.1.3.utmcsr=SOURCE|utmccn=CAMPAIGN|utmcmd=MEDIUM|utmctr=TERM|utmcct=CONTENT
    

    This is what a __utmz cookie looks like for an organic google search:

    140029553.1283957328.2.136.utmcsr=google|utmccn=(organic)|utmcmd=organic|utmctr=SEARCH-TERMS-HERE
    

    This is what a __utmz cookie looks like for a direct visit:

       17861479.1283957910.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)
    

    This is what a __utmz cookie looks like for paid google search with autotagging:

       175516223.1283957996.1.1.utmgclid=CLrr7fyL-KMCFZpN5QoduVOTLA|utmccn=(not%20set)|utmcmd=(not%20set)|utmctr=SEARCH+TERM
    

    PHP is not ideal, since you could never read the cookie on single-page-visits, but here is what the code could look like in PHP.

    if(isset($_COOKIE['__utmz']))
    {
    $cookie= $_COOKIE['__utmz'];
    $params =  strstr($cookie, 'utm');
    $cookiearray = explode("|", $params);
    $final = array();
    for($i=0; $i<count($cookiearray); $i++)
    {
        $temp = explode("=",$cookiearray[$i]);
        $final[$temp[0]] = temp[1];
    }
    }
    

    This would give you an array ($final) with key-value matches for each traffic source parameter.

    You’d probably be better off parsing this in JavaScript and posting it to your server using AJAX, rather than reading it on the server-side, since you could only do that on the second page view, and would thus lose the ability to track single-page-view users. This can be an annoying task with manual JavaScript, because both cookies and AJAX can be inconsistent across browsers, so I would recommend a framework like jQuery.


    Here’s the approach I would take using jQuery. I’d add the jQuery cookie plugin, and post it within a _gaq.push(function(){...}); clause like this (assuming that the PHP above is stored in handler.php).

    $.post('handler.php', '__utmz' : $.cookie("__utmz") );
    

    Then, switch the two references of $_COOKIE to $_POST, and do whatever you want with the array it produces.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So Google Analytics does not have an API that we can use to get
jQueryMobile loads its first page as every site does. The usual Google Analytics integration
I'm working on a project here that will store some info in Google Analytics
I need to make something like google-analytics, I mean that it has to be
I've created a pretty basic system here at work that does what Google analytics
How does one go about including Google analytics for Trigger.io-built apps? I can see
I have a site that uses google analytics and is that uses a number
Does anyone know how Google Analytics exports their PDFs? They don't seem to make
Does anybody know what google web master tools offer I have google analytics on
Does Google cap the number of connections a server can make to Google IMAP

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.