Closed beda closed 9 years ago
Hi, try this - I just tested and it worked for me:
var eventdata = {
actid: "",
key: "",
event: "nodejs_test",
eventdata: "test1",
visit: {email: "test@test.com"}
};
var log_event = ac.api("tracking/log", eventdata);
log_event.then(function(result) {
// successful request
console.log("log_event result");
console.log(result);
}, function(result) {
// request error
});
Make sure to fill in your actual account ID, key, and contact email address.
I enabled debug mode. I do:
ac.credentials_test().then(function (result) {
// successful request
if (result.success) {
var eventdata = {
actid: "myactid",
key: "mykey",
event: "nodejs_test",
eventdata: "test1",
visit: {email: "test@test.com"}
};
var log_event = ac.api("tracking/log", eventdata);
log_event.then(function (result) {
// successful request
console.log("log_event result");
console.log(result);
}, function (result) {
// request error
});
} else {
// INVALID ACCOUNT
}
}, function (result) {
// request error
});
I get this:
debug mode enabled
API request URL: https://trackcmp.net/event
Request options:
{ method: 'POST',
url: 'https://trackcmp.net/event',
body: 'actid=&key=&event=nodejs_test&eventdata=test1&visit=%7B%22email%22%3A%22test%40test.com%22%7D',
headers: { 'content-type': 'application/x-www-form-urlencoded' } }
log_event result
{ success: 1, message: 'Event spawned' }
the actid and key in the POST body are empty. Eventhough it says success the event does not show up.
Sorry about that. Here is a sample that works:
ac.version(2);
ac.track_actid = "myactid";
ac.track_key = "mykey";
ac.track_email = "test@test.com";
ac.credentials_test().then(function (result) {
// successful request
if (result.success) {
var eventdata = {
event: "nodejs_test",
eventdata: "test1"
};
var log_event = ac.api("tracking/log", eventdata);
log_event.then(function (result) {
// successful request
console.log("log_event result");
console.log(result);
}, function (result) {
// request error
});
} else {
// INVALID ACCOUNT
}
}, function (result) {
// request error
});
Ok, this works!
I wasn't able to pass in the actid, key and email. Couldn't find it in the documentation.