matomo-org / matomo-for-wordpress

Get a fully functioning Matomo Analytics for your WordPress. Star us on Github? +1. Matomo is the leading open alternative to Google Analytics that gives you full control over your data. Privacy is built-in. 100% data ownership, no one else can see your data. We love Pull Requests!
https://matomo.org
GNU General Public License v3.0
119 stars 25 forks source link

server side ecommerce tracking creates cookies even when cookies are disabled in settings #1077

Closed floek closed 8 months ago

floek commented 8 months ago

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:

image

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

diosmosis commented 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?

floek commented 8 months ago

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):

image

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:

image

When I disable ecommerce, the behavior is gone (of corse).

Best, floek

diosmosis commented 8 months ago

@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.)

floek commented 8 months ago

@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?

diosmosis commented 8 months ago

@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.

diosmosis commented 8 months ago

@floek were you able to check if this solution worked for you?

floek commented 8 months ago

@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

diosmosis commented 8 months ago

@floek Apologies, I should've explained:

To apply the change yourself you would need to:

You 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.

floek commented 8 months ago

@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?

diosmosis commented 8 months ago

@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.

floek commented 8 months ago

@diosmosis its https://www.tee-freund.de It happens in firefox. safari seems to behave differently.

diosmosis commented 8 months ago

@floek thanks, I can see the issue, I'll let you know when I figure out what's going on.

diosmosis commented 8 months ago

@floek can you try the following:

and see if that solves the problem for you?

floek commented 8 months ago

@diosmosis Yes, this seems to fix the issue! Thank your for your support!

diosmosis commented 8 months ago

@floek glad it's working, let us know if you need anything else.