• Resolved UmbrellaWeb

    (@umbrellaweb)


    Hi There,

    On multiple sites the error:

    There was an error setting cookie _pk_testcookie_domain. Please check domain and path.

    shows, its the same issue on inconito and private browsers. Running the latest seopress free. We can see that the file being used is matomo.php and the offending code is:

    $seopress_matomo_config['subdomains'] = "_paq.push(['setCookieDomain', '*.".get_home_url()."']);\n";

    @line 124 – This needs to be fixed as its pulling in the FULL url: https://www.example.com rather than JUST https://www.example.com OR example.com SO removing the protocol that would probarbly fix the issue. Have this on multplie sites so updating 1 to refelct is not a solution.. BUT until the plugin itself is udated happy to use a temp solution if you can provide one please..

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Benjamin Denis

    (@rainbowgeek)

    Hi,

    we have opened an issue to fix this with our next major update.

    ETA: january

    In the meantime, you can use this hook to filter the value:

    https://www.seopress.org/support/hooks/filter-matomo-cookie-domain/

    Thread Starter UmbrellaWeb

    (@umbrellaweb)

    Hi there, thats filter doesnt work. Copied and pasted as is into code snippets result is the same error:

    There was an error setting cookie _pk_testcookie_domain. Please check domain and path. matomo.js:12:282
    Can’t write cookie on domain *.https://website.co.uk

    Same on multiple sites. Do we need to replace anything in the filter provided?

    get_home_url() pulls in the WHOLE url including protocol which is where the issue lies I think.

    Plugin Author Benjamin Denis

    (@rainbowgeek)

    Yes you have to edit the filter by replacing get_home_url() with your own code.

    The solution here would be to use https://developer.www.ads-software.com/reference/functions/wp_parse_url/

    with get_home_url() to get only the host.

    Let us know if you need help with the code.

    Thread Starter UmbrellaWeb

    (@umbrellaweb)

    Thanks or the update…

    Well, rather than over complicate things and add in additional code to parse just the host… AS we are going to add the snippet in anyway the MOST SIMPLEST way to achieve the goal is to replace:

    $html = "_paq.push(['setCookieDomain', '*.".get_home_url()."']);\n";

    WITH

    $html = "_paq.push(['setCookieDomain', '*.website.co.uk']);\n";

    replacing website.co.uk with whatever you wish. Nice and simple and to the point (saves having to edit core file too).

    At least thats what we found to be the EASIEST way!

    Plugin Author Benjamin Denis

    (@rainbowgeek)

    Thank you for this update.

    We confirm that the fix is coming this month.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘_pk_testcookie_domain ERROR’ is closed to new replies.