I'm sending a link to a landing page to a number of different companies and need to be able to tell Google Analytics which company is viewing the page and when. I of course have my original link to the page tagged with UTM parameters accordingly, but I also need to build in a safety net in case someone passes the link around and removes that code.

The URL for the landing page looks like this:


The company_name part is not an actual directory on the server but part of a query string that I'm rewriting into the URI, so I don't believe I will be able to filter on that in Google Analytics. The company_name part will change depending on who I send it to.

So, I need to be able to add some sort of tag or flag in my GA code to tell GA which company is viewing the page.

How might I do that? What are my options?


Something like this should do the trick:

      1,                   // This custom var is set to slot #1.  Required parameter.
      'Company',     // The name acts as a kind of category for the user activity.  Required parameter.
      $_GET['company_name'],               // This value of the custom variable.  Required parameter.
      2                    // Sets the scope to session-level.  Optional parameter.

That must be called before you call _trackPageview(). You can read more about custom variables here: https://developers.google.com/analytics/devguides/collection/gajs/gaTrackingCustomVariables

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.