Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a configurable offset to Content Tracking with JavaScript #17601

Closed
JE4GLE opened this issue May 20, 2021 · 6 comments
Closed

Add a configurable offset to Content Tracking with JavaScript #17601

JE4GLE opened this issue May 20, 2021 · 6 comments
Labels
answered For when a question was asked and we referred to forum or answered it.

Comments

@JE4GLE
Copy link
Contributor

JE4GLE commented May 20, 2021

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
@JE4GLE JE4GLE added the Enhancement For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc. label May 20, 2021
@diosmosis
Copy link
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?

@diosmosis diosmosis added the Potential Bug Something that might be a bug, but needs validation and confirmation it can be reproduced. label May 20, 2021
@JE4GLE
Copy link
Contributor Author

JE4GLE commented May 21, 2021

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
Copy link
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
Copy link
Contributor Author

JE4GLE commented May 22, 2021

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

@diosmosis
Copy link
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
Copy link
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.

@diosmosis diosmosis added answered For when a question was asked and we referred to forum or answered it. and removed Enhancement For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc. Potential Bug Something that might be a bug, but needs validation and confirmation it can be reproduced. labels May 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
answered For when a question was asked and we referred to forum or answered it.
Projects
None yet
Development

No branches or pull requests

2 participants