Closed floek closed 8 months ago
Hi @floek, I have verified that when the "Disable cookies" option is selected, no new cookies are created when visitors view and order products. Can you tell me how you disabled your cookies in Matomo for WordPress and whether you deleted existing cookies before running your test?
Hi @diosmosis,
thanks for reaching out. My behaviour is as follows: I delete all cookies in Firefox, got to my shop and add a product to the shoping cart. Then the following cookies are created (including _pk_*
cookies):
When I navigate to another page, the _pk_
cookies are deleted. But, why have they been created in the first place?
Here are my matomo settings:
When I disable ecommerce, the behavior is gone (of corse).
Best, floek
@floek Interesting... disabling cookies is accomplished through calling the disableCookies
method in the JavaScript tracker. If it's not working just for ecommerce actions, that might suggest it's not being called in some situation. Perhaps trackEcommerceCartUpdate
is being called before disableCookies
.
Would you be able to check if this is the case for you? These calls would be output as <script>
s in the page's HTML or in AJAX HTML responses. (If you are not able to and are willing to share the website this occurs on you can email dizzy (at) innocraft (dot) com and I can check.)
@diosmosis Hm, ajax may be the cause. I'm using astra theme with an ajax "add to shopping cart" button. I will look into this. Is it possible to use a custom theme/plugin and a PHP hook to disable the cookies in every case?
@floek There's no way to do this externally, but this change should do it: https://github.com/matomo-org/matomo-for-wordpress/compare/ecommerce-disable-cookies?expand=1. Note: it will be included in the next release as making sure it's called is a good idea. That said, it would be helpful if you could make sure this is the case for your setup, just in case there are any other issues involved in your setup.
@floek were you able to check if this solution worked for you?
@diosmosis Sorry, my understanding was: I have to wait until the code change is delivered in a new version. I haven't tested further. But, I can do some tests, if required. What should I try? Best, floek
@floek Apologies, I should've explained:
To apply the change yourself you would need to:
/path/to/wordpress/wp-content/plugins/matomo/classes/WpMatomo.php
file with https://raw.githubusercontent.com/matomo-org/matomo-for-wordpress/10a9523caf079b33cd1f0ae1b9629d199ec5291f/classes/WpMatomo.php/path/to/wordpress/wp-content/plugins/matomo/classes/WpMatomo/Ecommerce/Base.php
file with https://raw.githubusercontent.com/matomo-org/matomo-for-wordpress/10a9523caf079b33cd1f0ae1b9629d199ec5291f/classes/WpMatomo/Ecommerce/Base.php/path/to/wordpress/wp-content/plugins/matomo/classes/WpMatomo/TrackingCode/TrackingCodeGenerator.php
file with https://raw.githubusercontent.com/matomo-org/matomo-for-wordpress/10a9523caf079b33cd1f0ae1b9629d199ec5291f/classes/WpMatomo/TrackingCode/TrackingCodeGenerator.phpYou can do this on your local environment since the issue appears for you there as well.
Normally I wouldn't ask but since I can't reproduce the issue you are facing, I do want to be sure this change works before releasing it.
@diosmosis I've tested it, but: It did'nt work. The cookies still appear. Can I insert some debug statements in the code to help identify the cause?
@floek can you share the website it occurs on? If so, email it to dizzy (at) innocraft (dot) com. I should be able to check with just that.
If not, you'll have to look at the generated HTML, check that there's always a _paq.push(["disableCookies"]);
or something like it before any ecommerce tracking methods.
@diosmosis its https://www.tee-freund.de It happens in firefox. safari seems to behave differently.
@floek thanks, I can see the issue, I'll let you know when I figure out what's going on.
@floek can you try the following:
/path/to/wordpress/wp-content/plugins/matomo/classes/WpMatomo/AjaxTracker.php
with https://raw.githubusercontent.com/matomo-org/matomo-for-wordpress/170a4da02af54339d8e64546eb179be6b283551e/classes/WpMatomo/AjaxTracker.phpand see if that solves the problem for you?
@diosmosis Yes, this seems to fix the issue! Thank your for your support!
@floek glad it's working, let us know if you need anything else.
Hi Matomo,
I've disabled cookies, but when ecommerce tracking is enabled and products are added to the shoping cart, _pk cookies are still created:
I'm on Matomo Analytics Plugin 5.0.5, Wordpress 6.4.3 and WooCommerce 8.6.1. It is reproducable in a local development environment.
How can I use ecommerce tracking without cookies?
Best, Floek