Content tracking, goals, and custom variables all show no data

I’m trying to track a banner ad, i.e. impressions of and clicks on an image. I have tried custom variables, content tracking (Content Tracking, Banner tracking: track impressions, Clicks on any piece of content · Issue #4996 · matomo-org/matomo · GitHub), and simple goals (adding the destination url as a goal). But in all three cases all I get is the information that “no data” is available for those reports.

I have also used campaigns to track visitors from newsletters. In that case, data shows up but seems very low and performing a click doesn’t show up in the report immediately.

Now I’m wondering what are possible causes for this behaviour.

The codes I used for custom variables and content tracking are:


<a href="http://example.com" onClick="piwikTracker.setCustomVariable('1','Testbanner', 'Click', 'page'); piwikTracker.trackPageView();" >
 <img src="https://example.com/someimg.png" alt="SOME ALT TEXT" border="0"/></a>
 <img  width=0 height=0 src="data:image/gif;base64,R0lGODlhAQABAIAAAP///////yH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" onload="piwikTracker.setCustomVariable('2','Testbanner', 'Impression', 'page');piwikTracker.trackPageView();">


<div class="piwik-trackcontent" data-name="Testbanner" class="subc">
<a class="piwik-trackclick" title="Testbanner" href="http://example.com">
<img class="piwik-banner" src="https://example.com/someimg.png" width="182" height="174" alt="">
</a>
</div>

Any ideas?

PS: Link to github is not working with [].