@mattab opened this Issue on October 4th 2018 Member

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
@fdellwing commented on October 5th 2018 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.

Powered by GitHub Issue Mirror