I am trying to register a button click event on a page. For this I created a custom click event under /Settings/Analytics/Page events/
and assigned it on a page.
But the problem is: button event gets registered in xDB at session end though the button was never clicked. Looks like Sitecore flushes all the events registered on the page.
I want authors to create custom page events and assign to a page, for example, "CTA Click", "Register Event click", "Learn More click" but register programmatically through javascript click events and avoid other events to flush to xDB.
I am able to call my custom register event from javascript click as below:
function trackClick(){
var dataValue = { "name": this.getAttribute("name"), "data": this.getAttribute("data"), "text": this.getAttribute("datatext"),"itemId": $('#hidItemGUID').val() };
var valstring = JSON.stringify(dataValue);
$.ajax({
cache: false,
url: "/Website/TrackEvents.aspx?query="+valstring,
contentType: 'application/json; charset=utf-8',
dataType: 'json',
success: function (data) {
alert("success");
},
error: function (data)
{
console.log(data);
}
});
But I am looking to avoid registering any event which are attached to the page but not necessarily triggered by the visitor. Any pointers on this?
Also, in xDB I noticed there are page events getting recorded with "Long running request" as the event name. Any clues where does this come from and how can I avoid?