Post

Track Multiple BTN Clicks on Page

Here we track button clicks with a specific classname. The tracking script we are using is for LinkedIn.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<script>

// Get all elements with the class "pop-action"

const buttons = document.querySelectorAll('.pop-action');

// Iterate through the NodeList of buttons and attach click event listeners

buttons.forEach(function(button) {
  button.addEventListener('click', function() {
    // Code to run when a button is clicked
    console.log(`Button "${button.textContent}" clicked.`);
    window.lintrk('track',{ conversion_id: xxxxxxxx });
    // You can perform additional actions here if needed
  });
});


</script>

This post is licensed under CC BY 4.0 by the author.