Solution to use href and onclick together in anchor tag.


Scenario : We have to track number of times link click by user (Using Adobe siteCatalyst).
We tried added onClick function with href attribute.
But when we use href it ignores onClick.

So we have use below alternative.

Link :
< a href="javascript:TrackSiteCatalystAndRedirect('event1','bannerimage','00000','SOME_PROD');">

Script :
< script type="text/javascript" language="javascript">
function ImageTracking(event, link, productId, productName) {
//Tracking code

}

function TrackSiteCatalystAndRedirect(event, link, productId, productName) {
ImageTracking(event, link, productId, productName);
window.location = "/product-results.aspx";

}



 


Comments

Popular posts from this blog

Dataverse D365 REST Web Api using client secret From Postman or Power Automate desktop (PAD) .

Chrome Extension to auto refresh Power BI report.

How to call SharePoint online rest APIs using postman?