set checkStorageTask to null in analytics.js
Asked Answered
G

0

2

I am working on a chrome extension and I want to use google analytics to track user data. I am trying to implement analytics.js/Universal Analytics in the same fashion as this tutorial and this tutorial and spent days trying to figure out why it wasn't working for me. Countless articles and online forums have suggested the only modifications I needed to make were setting the checkProtocolTask to null and setting the page when sending a pageview. Running analytics_debug.js, it gives me the error "Cookie write failed. Storage not available, aborting hit." All of the answers to this error online suggest a problem with the cookieDomain, but I tried various different possibilities and nothing worked for me. It was only when I tried setting checkStorageTask to null as well that it finally worked for me. But why did I need to do this, when I haven't found any other evidence of anyone else needing to do this to get analytics to work in an extension?

The checkStorageTask aborts the request if the tracker is configured to use cookies but the user's browser has cookies disabled. After some more research I discovered it is possible for a chrome extension to have it's own cookies, with the domain pointing to the extension ID, as shown in the answer to this question. Is it a problem with my browser individually, then? Or is it a larger problem that I just can't see? Any ideas are greatly appreciated!

Glamorize answered 13/1, 2021 at 17:6 Comment(3)
I am working on my chrome extension as well now, and I was trying to do the same thing, let me ask you two questions. 1. Are you using the new Microsoft Edge? 2. And are you trying to implement the analytics in background.js?Salt
@arbel03, nope its a chrome extension, meaning I'm using Google Chrome. And I have a separate script for analytics. I use message passing to let that script know when to send an event. I explained my implementation here #65511812, if this helps!Glamorize
I developed my extension using Edge - it runs on chromium so fully compatible, I figured I needed to include checkStorageTask as well, but in my background.js script. maybe you should add that note to the answer on the other thread, I think you mentioned it was needed for content scripts (?)Salt

© 2022 - 2024 — McMap. All rights reserved.