@JE4GLE opened this Issue on May 20th 2021 Contributor

Summary

When using the content tracking feature, the JavaScript tracker often detects content, which is not visible on the screen. This can be tested by creating a div with 100vw/vh width and height. Then adding another piece of content below. In my case, the second content is still tracked, without scrolling. So adding an offset in pixels, which an element has to be visible would be solving this issue.
This can either be defined globally on initialization of the tracking api: _paq.push(['trackVisibleContentImpressions', true, 750, 50]); // 50px offset
or per element using a tag: <div data-content-offset="50"></div>

Environment

  • Matomo Version: 4.3.0
  • PHP Version: 7.4.13
@diosmosis commented on May 20th 2021 Member

Hi @JE4GLE, thanks for taking the time to create this issue! From what I know, trackVisibleContentImpressions shouldn't track images that aren't visible. I tested it just now and it seems to work as expected (on Chrome). Could you provide an example HTML file where it doesn't work like this as well as the browser used to view the example?

@JE4GLE commented on May 21st 2021 Contributor

I think is was just a loading issue with some CSS, which got loaded after the initialization of the tracking code. This way, the page shifted a bit and moved the elements out of sight.

@diosmosis commented on May 21st 2021 Member

@JE4GLE so they were visible on page load for a brief moment, then the css moved or hid them, and the problem is that they were tracked before the css moved them, is this understanding correct?

@JE4GLE commented on May 22nd 2021 Contributor

Yes, I have one stylesheet for the whole page loaded at the end of the page (but before the tracking script)

@diosmosis commented on May 24th 2021 Member

Hi @JE4GLE, I tried reproducing this (w/ the stylesheet at the end of the page before the tracking), and was still not able to reproduce. Would you be willing to share the website that this is occurring on over email? If so email dizzy@innocraft.com. If you could also tell me what browser you're using that would help as well.

@diosmosis commented on May 25th 2021 Member

As discussed via email, this is likely a race condition with the stylesheet being loaded after the JS is executed. I'll close this for now, but feel free to reopen it.

This Issue was closed on May 25th 2021
Powered by GitHub Issue Mirror