Quantcast
Channel: Support & Bugs - Matomo forums
Viewing all articles
Browse latest Browse all 5831

Heartbeat for Image / Link Tracking possible?

$
0
0

Hi,
is it possible to wrap the Image-tracker which JS that on initial Page load the IMG gets requestet and after then, every 5-10 Seconds, same Link? If yes, do i have to add something else for that heartbeat request after initial?

<img referrerpolicy="no-referrer-when-downgrade" src="https://xxxx/matomo.php?idsite=XXX&amp;rec=1" style="border:0; position: absolute;" alt="" />

i have following but seems not working, request are all fine, every 10 Secs:

<script>
            function sendHeartbeat() {
            // URL Matomo
            const imageUrl = "https://xxxxxxx/matomo.php?idsite=xxx&rec=1&ping=1";
          
            // FEtch request
            fetch(imageUrl)
              .then(response => {
                if (response.ok) {
                  
                } else {
                  console.error("Error sending heartbeat.");
                }
              })
              .catch(error => {
                console.error("Error heartbeat: ", error);
              });
          }
          
          // every 10 secs heartbeat
          setInterval(sendHeartbeat, 10000);
          
          </script>

But i wont count seconds in Matomo Backend. Only while zapping through homepage…

5 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 5831

Trending Articles