segmentio / analytics.js-core

The hassle-free way to integrate analytics into any web application.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

'global' id in HTML tag causes analytics.js to fail badly

disruptek opened this issue · comments

If you, as I do, have a page with, say, a <div id="global">...</div> then analytics.js will load and run via the snippet, but will not overwrite the window.analytics variable and playback the stubbed call queue. A call to page() will be made with the defaults, but that's the only sign that anything at all happened.

And, yes, this absolutely gave me fits while trying to debug...

This is due to the lovely implicit id references and an issue in the insert-module-globals module that browserify uses to fill global references. would be fixed by browserify/insert-module-globals#48 if it ever merges. I can put in a workaround for this in our browserify process for analytics.js for now. I'll update you when its deployed

Thanks; that sounds better than an update to the docs. 😉

New version deployed. Let me know if its fixed for you

Sorry; worked around this and didn't bother to update the ticket. It appears fixed, thanks. 😄