Skip to content
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

Update JavaScript code in app/docs/faq to use window._paq instead of _paq #13539

Closed
mattab opened this issue Oct 4, 2018 · 3 comments · Fixed by #13674
Closed

Update JavaScript code in app/docs/faq to use window._paq instead of _paq #13539

mattab opened this issue Oct 4, 2018 · 3 comments · Fixed by #13674
Assignees
Labels
c: Platform For Matomo platform changes that aren't impacting any of our APIs but improve the core itself. c: Website matomo.org For issues related to our matomo.org website.
Milestone

Comments

@mattab
Copy link
Member

mattab commented Oct 4, 2018

our current JavaScript tracking code in https://developer.matomo.org/guides/tracking-javascript-guide reads:

  var _paq = _paq || [];

When people copy paste this line and code into other places like inside Tag manager containers, and this line is copied, then the _paq value ends up being set to empty array, because the global _paq is not available in the function scope.

But we want to make it easy for users to copy paste bits of the code without breaking things.
By changing the line to the line below, we make sure to always read the global _paq:

  var _paq = window._paq || [];

Steps

  • Confirm that using window._paq does not risk triggering errors on some browsers?
  • Update all user guides, FAQs mentions
  • Update developer guides mentions
  • Update product the JS Tracking code generated
@mattab mattab added this to the 3.8.0 milestone Oct 4, 2018
@fdellwing
Copy link
Contributor

Confirm that using window._paq does not risk triggering errors on some browsers?

To be safe, just use window['_paq']. That is supported by all browsers.

@mattab mattab modified the milestones: 3.9.0, 3.8.0 Nov 5, 2018
@tsteur
Copy link
Member

tsteur commented Nov 6, 2018

just tested var _paq = window._paq || []; and window._paq = window._paq || []; on browsers back to IE6 and Firefox 3 and worked fine. It's bit easier / nicer to read than window['_paq'] maybe

@tsteur tsteur self-assigned this Nov 6, 2018
@tsteur tsteur added c: Website matomo.org For issues related to our matomo.org website. c: Platform For Matomo platform changes that aren't impacting any of our APIs but improve the core itself. labels Nov 6, 2018
@fdellwing
Copy link
Contributor

It's fine for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: Platform For Matomo platform changes that aren't impacting any of our APIs but improve the core itself. c: Website matomo.org For issues related to our matomo.org website.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants