Get around ad blockers by allowing custom paths in sdk-js
Problem
Ghostery and probably other ad blockers block POST requests to URLs with "event" in the path, effectively blocking jitsu.
I was surprised to see this happen since one of the big value propositions for jitsu is getting around ad blockers and owning your own data. Ghostery blocks requests even when using a custom domain.
It took a bit of trial and error to figure out what was causing the issue. It appears that if "event" is anywhere in the URL pathname, Ghostery will block it. Modifying @jitsu/sdk-js to use /api/v1 instead of /api/v1/event allows the request to go through, confirming Ghostery only cares about "event" in the pathname... at least for now.
Solution
The ability to change the event api endpoint in the jitsu server and in the sdk-js client would make life a lot easier.
My current solution was to fork sdk-js, modify the pathname and send the request through a Cloudflare Worker proxy to my jitsu server.
At the very least, it would be great to allow for configuring the api path in the sdk-js client upon initialization. This would allow unmodified use of the client to route the requests through a proxy.
Side Note
Thank you for building jitsu! It's a game changer.
Doh! I read the code more closely and realized randomize_url does the trick out of the box.
It's probably worth updating the docs to make a note of this.
import { jitsu } from "@jitsu/sdk-js"
// Setting randomize_url to true will cause "event" to NOT be in the URL.
// Ghostery does not block this request.
const jitsu = jitsuClient({
key: "[TOKEN]",
tracking_host: "https://[CUSTOM_DOMAIN]",
randomize_url: true,
})
jitsu.track('some_event')