Created
October 12, 2024 18:47
-
-
Save pixelstorm/19600c84d6365c2ef0d187da4636832e to your computer and use it in GitHub Desktop.
Track button clicks with a specific classname. The tracking script we are using is for LinkedIn.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 | |
}); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment