Content Tracking - Interactions with iframe ads not working

Hello everyone,

I am currently digging into the posbilities of the content tracking functionality. With this, I’d like to meassure impressions as well as interactions of ads that are being placed on different positions at a website. Thereby, ads are being dynamically added by a content provider into different slots each of which being defined by an empty div-element on the page. Ads itself are then inserted dynamically with iframes into each div-element.
What I have achieved so far is getting tracking of impressions on these elements working. Each ad slot is then showing up as an individual content piece element. However tracking of any interaction (any kind of clicks onto an ad by a visitor) does not work. Clicks however are being tracked on other parts inside of Matomo (e.g. outlinks or within the history of a visitor).

I am wondering what I might have to do to make this also work with ads that are being served within an iframe? So far, I have tried the integration of tracking all as well as visible impressions in the tracker setup such as:

// first try
_paq.push(['trackVisibleContentImpressions']);
// second try
_paq.push(['trackAllContentImpressions']);
// third try
_paq.push(['trackVisibleContentImpressions', true, 750]);

Here is an example of an ad-slot:

<div id="ad-slot-xyz" data-track-content data-content-name="Ads" data-content-piece="Ad xyz"></div>

Is there anything else I need to add to make this work? Searching the forum didn’t give me the help I was hoping for getting this solved.

Components not served within an iframe are working perfectly fine with the content tracking functionality and interactions are showing up in the statistics.

Running Matomo version 4.12.3

Thanks for all your help on this.