Support » Plugin: Category Country Aware Wordpress » CCA & Cookie Notice = Google Analytics Issue?

  • Resolved dredd15

    (@dredd15)


    Hi there.

    I love the simplicity of this plugin. It works great for what I need, which is to display Cookie Notice, but only to EU visitors.

    However, either this plugin or Cookie Notice seems to be affecting how Google Analytics is recognizing visitors.

    For instance, organic traffic which previously showed up in Google Analytics as:

    google / organic

    … after using these two plugins, now shows up as:

    (direct) / (none)

    This seems to be occurring in countries where the Cookie Notice code does show, and also where it does not show.

    Any idea what’s happening?

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Author wrigs1

    (@wrigs1)

    Hi dredd15

    This is a side effect of the method CN uses for consent. Unfortunately, there is no perfect consent plugin.

    Most cookie consent plugins (with much additional work by site admins) stop cookies, by either:

    i. server side blocking the serving of code/content that sets cookies until visitor consent is given; or

    ii. requiring site admins to “hobble” scripts, say by changing the source tag (src=)to something not recognised by browsers e.g. src="https://goog.com/.... edited to cn-src="https://goog.com/.... They are served to the visitor but won’t run. If the visitor has consented to cookies then scripts are “de-hobbled” on browser/client side and executed.

    Both methods have pros and cons.

    Cookie Notice uses the server-side method. The first page (only) served to a new visitor won’t include the admin identified cookie setting scripts. To enable a new visitor, who then accepts cookies, to see this page with complete content/functionality the page then has to be reloaded from the server with missing scripts.

    Cookie Notice settings give you the option of whether this first page a new visitor visits should be reloaded. Currently CCA “tells CN” that this non-EU visitor accepts cookies and the first page must be reloaded with scripts. In the next CCA release reload will depend on your Cookie Notice reload setting. Remember if you are using CN correctly Google Analytics will not have been loaded initially (and will not record the new visitors first page UNLESS it is reloaded).

    Its early days for complicated GDPR and you can expect cookie plugins to improve.

    • This reply was modified 3 years, 7 months ago by wrigs1.
    • This reply was modified 3 years, 7 months ago by wrigs1.
    • This reply was modified 3 years, 7 months ago by wrigs1.
    Plugin Author wrigs1

    (@wrigs1)

    This is a Cookie Notice issue – however CCA provides a fix for your non EU visitors. See new documentation for CCA when used with Cookie Notice and Google Analytics Any queries relating to CCA/CN & Analytics are best posted on that page.

    Hope this helps.

    Hi wrigs1,

    Thank you for the URL line cn-reloaded=1 fix in 1.2.3 for non-EU visitors.

    We’re still experiencing the page reload, for non-EU visitors, and I’m confused why this is the case. I would have thought that the web server could see the non-EU visitor from the initial web page query and as such the first page delivered to the visitors browser would include everything – and thus NOT need a page reload (for CN to install the Google analytics and Facebook pixel information).

    Am I missing something here? Is it just the way CN works? The page reload is causing an unnecessary ~50% increase in page load time for our non-EU visitors (who are close to 100% of our customers).

    Kind regards,
    Michael

    Plugin Author wrigs1

    (@wrigs1)

    Hi Michael

    Yes you are quite right. Because we know whether a visitor is outside the EU before serving the page, we can choose to immediately serve “everything” to non-EU visitors avoiding the need for a reload.

    See this CCA How To: fixing Cookie Notice’s Google Analytics (and reload) issues. Because of CN’s reloading before inclusion of GA, first time visitor organic (referrer) info cannot be collected – but with CCA installed we can include scripts immediately, and fix the issue for non-EU visitors. I’ve extended the “How To” to cover preventing reload for non-EU. (tested and works for me)

    Let me know if this helps.

    Wonderful. This works. Thank you VERY much!!!

    Sorry for a followup question.

    After success with the CCA fix above, we enabled WP Super Cache and Country Caching for WP Super Cache, and the reload returned for non-EU countries. We then turned off both plugins, and the single load returned – as per your fix.

    Any ideas as to what is happening? Are there particular settings we should apply to Country Caching for WP Super Cache to ensure the double load doesn’t occur? We followed the instructions for Cookie Notice users…

    Thanks,
    Michael

    Plugin Author wrigs1

    (@wrigs1)

    Hi Michael

    Sorry, I’ve altered the “setcookie” arguments in the example (link above) to expire after 364 days and to have a “path” of “/”. I’ve tested with WPSC Country Caching; and scripts are served without a reload for first and subsequent pages providing the visitor is non-EU.

    If you were experiencing non-EU first page reloads then I don’t know why it didn’t arise when you weren’t using WPSC. To test (probably telling you what you already know):

    1. Clear browser cache for domain.
    2. Clear Cookies for domain.
    3. Go to WP Super Cache Settings -> “Content” (note WPSC may incorrectly report 0 cached pages) click “Delete Cache” or click “List all cached files” and delete individual cache for pages you want to test.
    4. In Cookie Notice “blocked scripts”->Body (presumably now empty) insert <script>alert('FOR NON-EU THIS SHOULD NOT APPEAR ON FIRST VISITED PAGE')</script> and save.

    As the alert says, it should NOT be displayed on first page ever visited for non-EU visitors. It SHOULD appear on subsequent pages (as CN will add it without reload).

    Thank you so much for your reply.

    I’m using Pingdom tools to check the website from different locations around the world. So I have no control over browser caching, but from experience, each Pingdom request seems to not involve local caching.

    I followed your instructions re WP Super Cache. Interestingly when I specifically delete the homepage from the “List all cached files” list, the 1st web query (from a non-EU country – e.g. Australia) does NOT do a reload, which is great. However any subsequent web queries from a non-EU country does do a reload. I can replicate this reliably be deleting the file from the cache, then doing requests from Australia, USA, etc.

    I’m not sure what else to do at the point except just not use WP Super Cache. From your notes under Country Caching for WP Super Cache support, I confirmed that “Cache delivery method” is set to Simple, and “Cache HTTP Headers with page content” is checked.

    Happy to move this to email if it helps. Got to https://southerlychange.net/ fill out the contact form and I’ll reply.

    Kind regards,
    Michael

    • This reply was modified 3 years, 6 months ago by msmithers.
    • This reply was modified 3 years, 6 months ago by msmithers.
    Plugin Author wrigs1

    (@wrigs1)

    Hi Michael,

    Sorry; I’ve been tied up today. Thanks for the contact link it’ll simplify diagnostics/testing (e.g. you can temporarily remove my country from lists of EU countries so I can see if I am affected by reload; and what cookies are added to my browser)). But v busy over next few days, so if you don’t hear from me tomorrow you can chase me via this link https://wptest.means.us.com/contact-us/

    I’ve tried various browsers and can’t replicate issue. I’ve not used (paid?) Pingdom tools and don’t know whether you are referring to use as an online proxy (if and how it stores cookies on navigation may impact, as they will no longer be stored by your browser under the relevant domain).

    I assume you are located outside EU and when not using pingdom browsers on your devices still reload?

    If you are based in the EU then you can still test non-EU behaviour locally with a variety of browsers by removing your country code and “EU” from the group/EU country lists in BOTH CCA and Country Caching settings (don’t forget to save settings). As before; once you have made these temporary changes you will need to clear browser cache and cookies for your domain in the browser; and as a minimum delete cache for all pages you intend to use to test landing and subsequent navigation.

    There is possibly an alternative method involving the editing of one line of code in your CCA plugin (which I could add to the next release of CCA) but I would prefer to avoid this and have a working solution without modification.

    Plugin Author wrigs1

    (@wrigs1)

    Update: On contacting msmithers I was able to replicate issue and produced a modified script for his issue. See revised custom script here CCA How To: fixing Cookie Notice’s Google Analytics (and reload) issues.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘CCA & Cookie Notice = Google Analytics Issue?’ is closed to new replies.