Dan0sz / host-analytics-locally

Automagically download analytics.js, keep it updated using WordPress' built-in Cron-schedule, generate the tracking code, add it to your site's header or footer and tons of other features!
https://daan.dev/wordpress-plugins/caos/
MIT License
11 stars 5 forks source link

AdGuard filters cookies #3

Open kklem0 opened 1 year ago

kklem0 commented 1 year ago

Hi, I'm a Pro user. I noticed that each view is considered a new user when using AdGuard, I haven't tested other AD blocker yet. Here's the filter log, you can see the filter rule.

Screenshot 2023-01-08 at 00 47 26
kklem0 commented 1 year ago

I guess if Cookieless works with GA4 it'll also be fine. Google Site Kit uses GA4, I'm using Google Site Kit with Compatibility Mode.

kklem0 commented 1 year ago

Can we replace _ga/_gat/_gid to somethine random first then change it back before forwarding to google?

kklem0 commented 1 year ago
        if (empty($_COOKIE['_ga'])) {
            if (!empty($_COOKIE['p7YwEk']) && preg_match('/[0-9]{10}\.[0-9]{10}/', $_COOKIE['p7YwEk'])) {
                $cid = $_COOKIE['p7YwEk'];
            } else {
                $cid = rand(1000000000, 9999999999) . "." . rand(1000000000, 9999999999);
            }

            setcookie('p7YwEk', $cid, time()+60*60*365*2);
            $params['cid'] = $cid;
        }

        if (empty($_COOKIE['_gid'])) {
            if (!empty($_COOKIE['25gXt4ZH']) && preg_match('/[0-9]{10}\.[0-9]{10}/', $_COOKIE['25gXt4ZH'])) {
                $gid = $_COOKIE['25gXt4ZH'];
            } else {
                $gid = rand(1000000000, 9999999999) . "." . rand(1000000000, 9999999999);
            }

            setcookie('25gXt4ZH', $gid, time()+60*60*24*2);
            $params['_gid'] = $gid;
        }

Dumb fix that works for now.

Dan0sz commented 1 year ago

Hi!

I'm sorry for not responding. I don't check Github that often, because I don't receive messages here often. :-)

I'm working on a Cookieless version of GA4 in the next release of CAOS Pro. Would that solve your problem?