I am trying to use event tracking via client side javascript.
I have a function that calls the event tracking endpoint:
function activeCampaignEvent(email) {
var url = "https://trackcmp.net/event";
var email = encodeURIComponent(email);
var event = "leadform-cta";
var id = "MY_ID";
var key = "MY_KEY";
var data = "actid=" + id + "&key=" + key + "&event=" + event + "&visit=%7B%22email%22%3A%22" + email + "%22%7D";
var xhr = new XMLHttpRequest();
xhr.open("POST", url);
xhr.setRequestHeader("content-type", "application/x-www-form-urlencoded");
xhr.send(data);
}
I get the following error when it is run:
XMLHttpRequest cannot load https://trackcmp.net/event. No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘MY_DOMAIN_HERE’ is therefore not allowed access.
I am able to execute a similar request via curl locally. And that does work. But of course I need to be able to call this request via my website too.
Any ideas? Thanks.