-
Notifications
You must be signed in to change notification settings - Fork 117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
exokit DOM doesn't support google analytics #1230
Comments
This would be more broadly, cookie support. I don't think |
Actually... It has nothing to do with When I set The fetch worked, and I erroneously assumed it was due to sending document.cookie. But in fact, it was the user agent. To be clear, if I right click ->
pasting that into exokit's CLI doesn't work. But if you add
to the fetch options, then it works. The final working fetch is:
whenever I paste that into exokit's CLI, google analytics sees it. I'm not sure why. But after checking and re-checking, I'm pretty confident this issue is solely due to the user agent setting. |
We do indeed use an Exokit-specific user agent. Does that mean that this issue is resolved? |
No, I don't think so. If you grep the codebase for It's using the default value of the |
I can confirm that changing every Is there a better way to access |
https://stackoverflow.com/questions/16010204/get-reference-of-window-object-from-a-dom-element seems to work:
|
Thanks for the investigation here. It sounds like the forward-compatible way to handle this case would be to finish the intercept support and perform that interception to set the User-Agent header. |
Describe the bug
What happened, and what did you expect to happen?
I created a basic index.html with google analytics, then deployed it using
now
. When I visit the resulting url in chrome, I see the visit in my google analytics page.When you go to the page using exokit, the google analytics javascript executes (e.g.
ga
is defined globally, as expected). However, on the google analytics dashboard, nothing happens. (It should show that a user visited the site.)The root problem is that exokit's
fetch
function doesn't sendCookie: ${document.cookie}
in the request.You can prove this by making an html page with google analytics, copying the
collect?v...
request asfetch
, then pasting the resulting fetch into exokit's CLI. Google analytics won't see anything. If you add 'headers: { 'Cookie': document.cookie }` to the fetch options, everything works fine.One fix is for
window-fetch
to check whethertypeof document !== 'undefined'
, and if so, set'Cookie': document.cookie
in the headers. What do you think the best way to fix this would be?document.cookie should probably be saved to some kind of persistent storage, too (if it isn't already).
The text was updated successfully, but these errors were encountered: