@manuscle wrote:
How can I load matomo on document ready?
I have to load the script when $.cookieAccepted() is true (I’ve checked its value and it’s true), but seems the matomo.php not reached.Here is the code snippet:
$(document).ready(function () { if ($.cookieAccepted()) { var _paq = window._paq || []; /* tracker methods like "setCustomDimension" should be called before "trackPageView" */ _paq.push(['trackPageView']); _paq.push(['enableLinkTracking']); (function() { var u="//analytics.myCompany.com/"; _paq.push(['setTrackerUrl', u+'matomo.php']); _paq.push(['setSiteId', '3']); var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s); })(); } });
Posts: 1
Participants: 1