Hi there.
i am trying to send a custom event from javascript on a website, using the information from the developer API Guides — Piwik PRO Analytics Suite 16.35 documentation. but it does not work. see below script.
pageviews and other tracking is working. anyone have some insight ?
i am trying to send this event:
<script type="text/javascript">
var _paq = _paq || [];
_paq.push(["trackEvent", "MyCustomEvent", "dataName", "Testing the data"]);
</script>
thanks.
i have added the custom event to another website were we are using piwik and there the custom event works as expected.
what do you mean excactly with main analytics script ? we can see pageviews etc, would that be possible without the main analytics script ?
ok we changed, some consent settings in analytics setup and now the custom event is working from the console. but it is till not working from the website.
Solution: If a custom event code is executed inside a function before loading the container (and effectively the analytics JS library), you have to define it in the global scope via window._paq. Otherwise it’s likely that _paq would be defined just as a local variable.