Having "utm_" in the URL string breaks the $_GET variable in Wordpress
php, varnish, wordpress
Solution
In case anyone else runs into the same problem, as I just did, I spoke with WPEngine support team via Live chat and. They rectified it within a few minutes
Here's a shortened transcript of our chat:
- Me: I'm trying to put some GET vars into a cookie and it seems like it works for arbitrary variables (like my_name=bob) when accessing the $_SERVER['REQUEST_URI'] global variable, but for some reason anything starting with "utm_" in the query string is being stripped out. Seems to be a php/cache config on your side, do you know anything about this?
- WPE: Great question; unfortunately, I am not aware of anything automatically stripping out specific args within a query. Let me review this with some colleagues.
- Me: k. FYI, here's a stack overflow issue http://stackoverflow…-the-get-variable-in-wordpress. seems to be corroborated by others' experience as well: https://twitter.com/…ey01/status/555584796785528832
- WPE: This is for the your install: ?
- Me: yes
- WPE: Can I please have you try now?
- Me: ok, it works now. what was the issue?
- WPE: Excellent! The issue was that we strip out the "utm_" arg by default. I apologize for not realizing the arg that you were suggesting. I had to exclude this arg from our caching system.
- Me: ok, so there's no way I could have done that myself right?
- WPE: That is correct.
Link for reference: https://wpengine.com/support/utm-gclid-variables-caching/
Problem
First note: This site is hosted on WPEngine (varnish caching), but I can't seem to replicate the issue on another server. We need to be able to access the $_GET php variable on some pages. For testing, I modified our Wordpress header.php to do a var_dump on the very first line. Normally, everything works OK. However if the URL string contains "utm_", every subsequent variable in $_GET is stripped. The extra weird part is that if I am logged in to Wordpress, everything works fine. Our Paypal return URL looks like this: http://oururl.com/buy/thankyou/?utm_nooverride=1tx=xxxxyyyy... The utm_nooverride causes the $_GET to be an empty array. If I change it to "test=1&tx=xxxxyyyy", it works OK. If I use "utm_test=1&tx=xxxxyyyy" I get an empty array again. There is nothing odd in the .htaccess, only a few standard Wordpress lines. Could there be something in the hosting causing this?