-1

I’m trying to create a heatmap. When a user clicks anywhere on my website, I track the x/y coordinates and save them to the database. In my dashboard, I load the website inside an iframe and display those coordinates as a heatmap overlay.

The problem is that the entire website doesn’t fit inside the iframe at once, so scrolling throws off the coordinates. The iframe width also doesn’t match the original website’s width, so the points don’t appear in the correct positions.

What’s the best workaround for this? How can I accurately display the heatmap on the iframe without the coordinates getting messed up?

4
  • 1
    I track the x/y coordinates...might it be better to track the HTML elements they clicked on instead? Depends on the purpose of the heatmap I guess and what else you might do with the data, and how dynamic the site is Commented 2 days ago
  • Alternatively you could get the current scrollPosition using JS to understand the vertical and horizontal offset of the site, and use that to adjust your co-ordinate calculation - see stackoverflow.com/questions/2481350/… Commented 2 days ago
  • How are you looking at the coordinates? Are you using %s. It's a bit difficult to help without seeing the relevant code. Commented 2 days ago
  • A minimal reproducible example of the issue would greatly improve this post. See also How to Ask. Commented 2 days ago

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.