I'm trying to track the contacts by logging them into a DE as soon as they click on a CTA on cloud page. I'm using onclick event and passing the value to a variable and then trying to pass the Javavar variable value to ampscript variable. For some reason am having issues passing java variable to ampscript variable. Can you please suggest a best practice to achieve this.
Here is my code,
<a id="abc" value="clicked" onclick="return check()" href="https://salesforce.stackexchange.com/" class="xyz">Click here</a>
<script runat=server>
Platform.Load("core","1");
function check()
{
var javavar = document.getElementById("abc");
Variable.Setvalue("@ampscriptvar",javavar);
}
</script>
Based on AMP Script value I'm inserting the contact information to a data extension using InsertDE function.
How to determine if someone clicked on the CTA?