Cache and utm/gclid Variables

Identifiable parameters are often attached to URL (such as gclid or utm) to better track information such as referrer or visits on a website. When we see tracking parameters on a URL instead of placed with JavaScript our servers automatically sanitize the URL. This is done in order to maintain cacheability and protect the overall stability of your site.

Learn more about why WP Engine sanitizes URL parameters and what to do if there are issues with URL tracking parameters.

About URL Variables

Site managers may wish to use specific URL queries, also called parameters or variables, to track how traffic is reaching a particular page. Google Analytics is one of the more common services employed to track visitors and view whether their advertising campaigns have been successful.

Tracking can be done by adding variables to the end of URLs based on the source the traffic is coming from. With Google Analytics these variables, or parameters, in the past have typically been utm_ and gclid.

Here’s an example of a URL that has utm_ variables added:

In the example above we can see the variables utm_medium, utm_source, utm_campaign, and utm_content have been added. In this case we’re showing a link that WP Engine shared on Facebook, so we could track traffic that came from social media to this specific blog post.

To read more about what each of these variables means in regards to tracking a site’s traffic data, check out this information from Google Analytics.

URL Variables and Cache

While most often these variables are used for tracking purposes, they sometimes might be used to actually perform an action for visitors based on the referring URL or campaign. For example, a site manager might want to display a different banner or popup for users who came to the site from different sources, or add a specific item to the cart based on a referral link. In these cases, the intended action may run into conflicts with the WP Engine server caching system.

In a normal request, adding a variable to the end of a URL will tell the server to treat the request as a brand new page, which means the entire page would be uncached and generated as completely new with each request.


Need a caching refresher? See the Server Cache Guide.

Uncached requests require more server resources than cached requests meaning too many uncached requests can result in 502 or 504 errors. If you’re running a campaign using URL variables to drive traffic to the site, but all those requests are uncached, it’s a simple recipe for a server disaster. Ideally there should be as few uncached requests to a website as possible, to ensure it can scale successfully with more traffic.

In WP Engine’s cache configuration, we have specific measures in place to ensure that adding URL variables does not cause the page to serve uncached. We call this process “sanitizing”: A request is received by the server and the utm_ or gclid variables are stripped from the end of the URL before sending the request to be generated by PHP. Once the request is compiled, the variables are re-attached to the URL to be returned to the user.

Potential Conflicts

For most tracking purposes with Google Analytics, this still allows campaigns to be tracked properly as the code is tracked and sent to Google Analytics via JavaScript. However, if attempting to execute a specific action based on these variables, there may be conflicts with the WP Engine caching system.

Bear in mind, it’s far better to ensure that any action based on these variables is either executed with JavaScript or to use a variable of a different name (not utm_ or gclid).

If there is minimal traffic coming into the variable and it’s absolutely necessary, users can contact WP Engine Support through the User Portal to request a cache exclusion. When contacting Support, please have the following information ready:

  • Environment name affected
  • Example of an impacted URL
  • Replication steps for the issue
  • Which variable (utm_banner, utm_campaign, etc.) will be added to URLs
  • Approximate percentage of traffic that will be using these variables

It’s very important to understand that excluding these variables from cache could very easily cause performance issues for the site. If the site runs into issues and errors because too many uncached requests are coming in, WP Engine reserves the right to remove problematic cache exclusions.

If a lot of the site’s traffic uses these variables, much more traffic will be uncached as the server will have to generate each request as new. This means the site will not be able to scale to support as much traffic as it would if it were taking full advantage of our caching layer.

NEXT STEP: Leverage browser caching with cache-control headers

Geographically customize content

Customize page content for your users based on their location without compromising cache or performance using WP Engine's GeoTarget.