The Issue

Every now and then, a site running on WordPress will not accurately record Google AdWords visits in Google Analytics. You may notice that the number of AdWords clicks reported in Analytics is correct, but it records nearly zero visits. In fact, another symptom is that no Analytics campaign visits (including those campaigns defined using the Google Analytics URL Builder) are being recorded.

The Why

Google Analytics gets all of its visit data from the query string of a URL. This is the part of the URL that follows the full path, begins with a question mark, and contains a series of parameters (or at least one parameter). This is most visible when defining a custom campaign – it looks something like ?utm_source=newsletter&utm_medium=email&utm_campaign=promo – but, in fact, Google AdWords has been “auto-tagging” destination URLs for enhanced ad performance tracking in Analytics for quite some time. You may have seen clues pointing to this – the Google AdWords query string parameter is GCLID.

All of the preceding information is important because it gives insight into what can go wrong with this type of tracking. Every now and then, a WordPress plugin will issue 301 redirects for any URLs containing (unrecognized) query strings, and direct them to the same destination without those parameters. Because the Analytics tracking code is contained within the page itself, it will only be called after the page loads from the resulting 301, and Analytics will no longer have any query string data to provide insight into the source of the visit.

The Fix

Because this is typically caused by a plugin, fixing it requires changing a plugin setting generally related to permalinks.

In the WordPress SEO Plugin by Yoast, the setting responsible for this is the “Clean Permalinks” option, as discussed here. They seem to have addressed the Analytics tracking issue, while preserving the overall idea, with the advanced option “Prevent cleaning out Google Analytics Campaign Parameters”, documented here. I have not tested this resolution, and if it does not work for AdWords tracking, then try adding the GCLID parameter to the list of “not to clean” variables.

In the 404 Redirected plugin, navigate to the plugin’s settings, and select the “Options” tab above. Scroll down, and near the bottom, disable the “Force current permalinks” setting.

If you notice this happening despite the plugin settings above being correct, it is probably caused by a similar plugin with a similar setting. To narrow it down a bit more manually, try to disable plugins until you confirm that http://www.example.com/page/?test=true (replaced with an appropriate page for your site, of course!) returns a 200 status code with the correct page contents, and not a 301 redirect to http://www.example.com/page/.

Postscript – But the “Clicks” Count is Correct in Analytics?

The avid reader and/or troubleshooter will point out that the “clicks” count is correct in Analytics, so how can this indicate a problem with Analytics tracking? The answer is that the “Clicks” count comes directly from the Google AdWords click data (as visible in Google AdWords without Analytics even running), which is “shared” to the Analytics platform via Google’s internal data sharing settings. The issue here is with the data being recorded by Analytics, and that would be the “visits” data.