Code Monkey home page Code Monkey logo

save-analytics-from-content-blockers's Issues

GA Changes on 17th Feb

It looks like GA made some changes to the JS on 17th Feb and this script in the current form no longer works.

It alters one GA with an incomplete record and makes it unusable so maybe worth considering for anyone yet to roll out.

When will the update come out?

Thank you for the current solution. According to the readme, there will be a "more robust solution". I'm really looking forward to it. May I ask is there an estimated arrival time?

uBlock Origin Blocking */gtag/js*

I use uBlock Origin, and after testing my implementation, it looks like this won't work for any adblocker that uses https://easylist.to/easylist/easylist.txt because it has a filter for /gtag/js?

I masked my googletagmanager URL using npm run mask www.googletagmanager.com/gtag/js?id=XYZ
and I have a reference to that in my app's javascript

adblock_network_calls

In the network calls, it redirects from the mask to http://MY-DOMAIN/www.googletagmanager.com/gtag/js?id=XYZ&l=dataLayer&cx=c which then gets blocked by uBlock Origin.

Not sure if this is anything that can be addressed on the implementation side, but just wanted to report this since I saw from #14 (comment) that @ZitRos you use AdGuard (tracking works when I enable AdGuard instead of uBlock Origin)

Change cache headers to public?

Files like www.googletagmanager.com/gtag/js return cache-control: private, max-age=900.

I suggest modifying it to public as it should be safe and will save a lot of load on the servers, what do you think?

Which third party scripts do you need help with?

I'm pretty motivated to get this working for a GTM set up. Where can I see the scripts you've already got this working with?

Outside of setting X-Real-IP, X-Forwarded-For and "uip," is there anything else that needs to be done for IP address forwarding?

Is it still working?

Hi @ZitRos,

Thanks for this excellent and unique tutorial.
I tried to implement this solution with the only difference that I used NGINX for the proxy.
Everything looks fine excepts that I don't see any visits in the Google Analytics console.

I can see that the "collect" request and the 200 response in the Developer Tools, but the Tag Assistant says "No HTTP response detected."

I'm pretty sure I did everything as told, and I don't believe the proxy would make any difference.
So, I'm wondering if this technique still works according to your own experience?

Regards,
Benoit

"Proxy error: domain \"gas\" is not proxied. Requested URL: /gas/"

I've been trying this out but keep coming up against the above error. When running via NPM I see:

Environment variables:
APP__STRIPPED_PATH=/gas (a prefix path added to the original host, which will be removed in the proxy request)
APP__PROXY_DOMAIN= (an optional proxy domain which will be used for client-side requests instead of the current domain)
APP__ENV_NAME=local (should not be local nor test in production)
APP__HOSTS_WHITELIST_REGEX=/.*/ (YAY!! Anyone can use your proxy!)
2021-10-26T18:30:07.999Z Analytics proxy web server is listening on port 80

As the proxy domain is optional, I've not changed that.

Any clues that you could provide as to where I am going wrong, or what i've missed?

[Question]: Github static gh-pages

Is there a way to prevent Google analytics being blocked by ad blockers for static gh-pages without requiring a server-side solution?

Weird behaviour: Google Analytics reports visits but realtime counter stats at zero

Hi! I am testing this solution to try and fix GA's stats. The idea is brilliant! :)

I am seeing something weird though. The script is proxied etc and in the realtime view of GA I can see something in "Top Pages" as I visit pages, but the "active users" counter stays at zero as if something is missing in the tracking. Any idea of how to fix? Thanks!

ps. when will the service be available?

Proxy doesn't start in Plesk

Hello,

I'm trying to configure the proxy in Plesk according to this guide: https://docs.plesk.com/en-US/onyx/customer-guide/nodejs-support.76652/, but it tells me that there is no app.js file. Here I tried to put it pointing to src/api.js, but it doesn't work.

If I'm going to execute script and run "start", I get the following error:

> [email protected] start /var/www/vhosts/domain.com/gtm.domain.com
> node -r esm src/api.js

npm WARN lifecycle The node binary used for scripts is /usr/bin/node but npm is using /opt/plesk/node/8/bin/node itself. Use the `--scripts-prepend-node-path` option to include the path for the node binary npm was executed with.
/var/www/vhosts/domain.com/gtm.domain.com/src/api.js:18
export async function init () {

SyntaxError: Unexpected token function
    at Object.Module._extensions..js (module.js:586:10)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: `node -r esm src/api.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     [/var/www/vhosts/domain.com/.npm/_logs/2019-09-05T10_03_59_393Z-debug.log]

I attach the generated log: 2019-09-05T10_03_59_393Z-debug.log

Regards,
Jordi

Using path instead domain for multidomain webpages

Hello,

I'm trying to configure this proxy to prevent the block of google scripts on my site, and finally I've made it work. All scripts are loaded from my site and url are replaced inside that files without problem.
My problem is that proxyDomain is mandatory, and I just want to use the domain where i'm doing the request.
In some files I can just leave it empty or just add the path, but when the source scripts have double slash (//) then it fails, for example //www.googleadservices.com

I don't know about JS or NodeJS and i'm was not able to fix it. Is possible?

Thanks!

How to use Dataunlocker in nextjs13?

I tried adding the script as a client component and importing it into the layout file, and it doesn't seem to be working. On the dashboard, I can see the count api.dataunlocker.com increasing but that's it. google analytics or tag manager arent being proxied.

On the other hand if I inject the script via tampermonkey on the same site it seems to be working normally.

Confused on what to do

Help needed with Step 3: Implementing the Simplest Proxy Server

Hey there,

I tried to follow your tutorial on https://www.freecodecamp.org/news/save-your-analytics-from-content-blockers-7ee08c6ec7ee/

And i managed to get things running but i'm stuck at Step 3: Implementing the Simplest Proxy Server

When i browse to http://my-ip/index.html

I get:

Proxied: www.google-analytics.com/r/collect?v=1&_v=j80&a=1503182168&t=pageview&_s=1&dl=http%3A%2F%2Fipremoved%2F&ul=en-us&de=UTF-8&dt=Google%20Analytics%20Test%20Proxy&sd=24-bit&sr=1920x1080&vp=1034x898&je=0&_u=AACAAEAB~&jid=1401297639&gjid=114978947&cid=88200760.1581435787&tid=UA-removed-1&_gid=1603874559.1581435787&_r=1&z=2065047711&uip=maskedip
Proxied: www.google-analytics.com/analytics.js

So it seems to be running.

Problem i get stuck is this:
Gathering all the files in the example together (see GitHub), we should end up with the following JavaScript server code:

var express = require("express"), 
    proxy = require("express-http-proxy"), app = express();

app.use(express.static(__dirname)); // serve static files from cwd

function getIpFromReq (req) { // get the client's IP address
    var bareIP = ":" + ((req.connection.socket && req.connection.socket.remoteAddress)
        || req.headers["x-forwarded-for"] || req.connection.remoteAddress || "");
    return (bareIP.match(/:([^:]+)$/) || [])[1] || "127.0.0.1";
}

// proxying requests from /analytics to www.google-analytics.com.
app.use("/analytics", proxy("www.google-analytics.com", {
    proxyReqPathResolver: function (req) {
        return req.url + (req.url.indexOf("?") === -1 ? "?" : "&")
            + "uip=" + encodeURIComponent(getIpFromReq(req));
    }
}));

app.listen(1280);
console.log("Web application ready on http://localhost:1280");

Were should i place this code or what should i do with this code?

Facebook Pixel event not fired

Thank you for the very excellent repo.
I installed it successfully, and it works fine with GTM and GA.
However, when adding Facebook Pixel in GTM. The Facebook Pixel script is fully loaded through the proxy, but no Pixel Event is fired.
Have you tried FB Pixel yet? Please give me suggestions to get FB Pixel working.
Thank you very much.

/ga-audiences

It appears when Signals data is turned on, the browser makes a call to a google page for /ga-audiences.

This does not appear mapped so some browsers will try and connect to a Google server.

In our instanace the URL in the javascript seems half encoded but half not.

https://www.%/*(YWRz)*/ga-audiences

It won't work with Google Tag Manager

In your article Google Analytics is described.
Google Tag Manager now replaces Google Analytics and is different. GTM first load a js file. That js file then loads "google-analytics.com/analytics.js".

However, there's no difrect link to "google-analytics.com/collect" in analytics.js anymore. Instead there're different kinds of other links to:

Which ones should be proxied? Which ones not?

How to work with all that now?

doubt: shared webhost

is there any way that we can run the setup on a shared webhost that the most '' advanced '' access is PHP / SQL / ???

I have a serious adblock problem holding our statistics, we use customized Wordpress by ourselves, but we have this limitation of the webhost

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.