Cache and utm/gclid Variables

Identifiable parameters are often attached to URL (such as gclid or utm) to better track things like referrers, visits and more on a website. When setting these tracking parameters on a URL, instead of with JavaScript, WP Engine automatically sanitizes such links in order to maintain cacheability and protect the overall stability of your site. Learn why WP Engine sanitizes URL parameters and what to do if you have issues.


About URL Variables

Site Managers may wish to use specific URL queries to easily track how traffic is reaching a particular page. Most often, Google Analytics is one of the services employed to track visitors and view whether their advertising campaigns have been successful. This tracking is sometimes done by adding variables to the end of URLs based on the source the traffic is coming from. With Google Analytics, these most often end up being utm_ and gclid variables. Here’s an example of a URL which has utm_ variables added:

https://wpengine.com/blog/todays-cybersecurity-landscape/?utm_medium=organicsocial&utm_source=facebook&utm_campaign=wpeblog&utm_content=cybersecurity

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

To read more about what each of these variables means in regards to tracking your 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. If you’re not familiar with server caching, we suggest a quick refresher from our 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 your site, but all those requests are uncached, it’s a simple recipe for a server disaster. Ideally you want to have as few uncached requests on 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 your campaigns to be tracked properly as the code is tracked and sent to Google Analytics via JavaScript. However, if you also want to execute a specific action based on these variables, you may run into conflicts with our caching system.

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 affected URL
  • Replication steps for the issue
  • Which variables (utm_banner, utm_campaign, etc.) will be added to URLs
  • Approximate percentage of traffic using these variables

It’s very important to understand that excluding these variables from cache could very easily cause performance issues for your site. If your site runs into issues and errors because too many uncached requests are coming in, WP Engine reserves the right to take out cache exclusions if necessary. If a lot of your 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 your 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

Still need help? Contact support!

We offer support 24 hours a day, 7 days a week, 365 days a year. Log in to your account to get expert one-on-one help.

The best in WordPress hosting.

See why more customers prefer WP Engine over the competition.