Skip to main content
Solved

Implement track api post request using javascript ajax

  • June 1, 2023
  • 1 reply
  • 202 views

Forum|alt.badge.img+1

$.ajax({

headers: {

Accept: "text/html",

"Content-Type": "application/x-www-form-urlencoded",

"Authorization": "WfkrbC"

},

type: 'POST',

url: 'https://a.klaviyo.com/api/track',

success: function (response) {

console.log('sent');

console.log('------>', response);

}

});

 

Hi, can someone help what is wrong in my code, the issue shows in my console is BLOCKED BY CORS POLICY ISSUE

What im trying to achieve here is to see, if the track api is working

Best answer by Brian Turcotte

Hi @jowin!

It appears you’re trying to create an event in the front-end, but the endpoint you’re using is meant for server-side calls only, which is why you’re receiving that error. Instead, I would recommend one of these two alternative APIs:

 

I hope this helps, and thanks for using the Community!

- Brian

View original
Did this topic or the replies in the thread help you find an answer to your question?

1 reply

Brian Turcotte
Forum|alt.badge.img+37

Hi @jowin!

It appears you’re trying to create an event in the front-end, but the endpoint you’re using is meant for server-side calls only, which is why you’re receiving that error. Instead, I would recommend one of these two alternative APIs:

 

I hope this helps, and thanks for using the Community!

- Brian