Salespanel.io automatically tracks web page views, form submissions, newsletter submissions, and support chat submissions out of the box. However, there may be times when you want to track every click of a button, menu item, or link on your website. In this article, we'll show you how to use a custom JavaScript tag provided by Salespanel.io to achieve this.
Step 1: Obtain the Custom JavaScript Tag: This custom JavaScript tag is provided by Salespanel.io at the top of the standard Salespanel JavaScript tracking code. This tag below will allow you to track button clicks, menu items, and links on your website.
<script>
document.addEventListener("click", function(event) {
if (typeof($salespanel) !== "undefined" && event.target.tagName) {
payload = {
"page_url": window.location.href
};
if(!['A', 'BUTTON', 'INPUT'].includes(event.target.tagName)){
return 1;
}
if (event.target.tagName == "A") {
payload["target_url"] = event.target.href;
} else if (event.target.tagName == "BUTTON" || event.target.tagName == "SPAN") {
payload["target_button_value"] = event.target.value;
payload["target_button_text"] = event.target.text;
}
var identifier = event.target.title || event.target.name || event.target.text || event.target.value || event.target.textContent;
if(identifier!=''){
try{
$salespanel.push(["set", "activity:customActivity", "website", "clicked on", identifier, payload]);
}catch(e){
console.log('SP: event not captured');
}
}
return 1;
}
});
</script>
Step 2: Install the Custom JavaScript Tag: To install the custom JavaScript tag, place it near the Salespanel tracking code on your website. This will ensure that all clicks on buttons, menu items, and links are sent to your Salespanel account.
Step 3: Verify the Tracking Code: Since the implementation might be technical, it's essential to verify if the tracking code is working correctly on your website. You can do this with the help of your developer, or by contacting Salespanel.io support for assistance. Verifying the tracking code is crucial, as other events installed on your button clicks or links might affect the expected outcome.
Step 4: Monitor the Results Once the custom JavaScript tag is installed and verified: You can monitor the tracked clicks in your Salespanel account. This will provide you with valuable insights into user behavior on your website. Please check out the expected outcome sample below.
Please check this video to get more details: https://www.loom.com/share/a8472802f6154b00b20b49166c608d82
Expected outcome:
https://www.loom.com/share/d10541d56d9b407fba7c7fe1ac6c9628
The custom JavaScript tag provided by Salespanel.io is a powerful tool for tracking button clicks, menu items, and links on your website. Although the implementation might be technical, with the right assistance, you can ensure that it's working correctly and providing you with valuable insights. If you need help or have any questions, feel free to contact the Salespanel.io support team.