1

I am trying to send an event using the SendInBlue API here.

When I send the event, it returns a 204 correctly - but I am not getting any events here and I have created an automation flow which is triggered by the event, and it does not send.

const axios = require("axios");
const url = 'https://in-automate.sendinblue.com/api/v2/trackEvent';

(async() => {
    try {
       const event =  await axios.post(
            url,
            JSON.stringify(            {
                email: 'myemail@emailprovider.co',
                event: 'USER_SUBSCRIBED'
              }),
              {
                Accept: 'application/json',
                'Content-Type': 'application/json',
                'ma-key': 'xkeysib-MY_v3_API_KEY'
              },
        );
            
    console.log(event);
    } catch (err) {
        console.log(JSON.stringify(err))
    }
})();

Is there a way I can see the events from this call coming in on the console?

James
  • 659
  • 1
  • 5
  • 25

2 Answers2

6

The ma-key is not the same that API KEY. You should use the ma-key instead your current API for the automatization key. After a couple of mails and a phone call, i figured out where is the ma-key:

You should login at send inblue. Click on Automatization (top menu). Click on Config (left tab bar). Click on something like 'see tracking code'. Then, you see a JS code. In this code, there is a key on it. This is your key.

My panel is in Spanish so maybe the words are not the same. Cheers.

  • How can this ever be safe? You basically extract a key from a client side code snippet, and use that to authenticate yourself on the server side? What stops me from getting someone's client key and fire a bunch of fake events? – binoculars Jan 26 '22 at 14:27
2

As far as I know you can't really see the events in the console. If you just want to make sure it's working you can

  • go to automation
  • start a workflow
  • Select a trigger: Website activities => An event happens

If you can select your event it means it worked.

Sendinblue is more a marketing automation tool and not an event analytics. So I'm not surprised you can't see the event in the GUI. If you want to see the events, try something like Mixpanel.

As @hector said pay attention to the API key. you're using the V3 campaigns (emails, contacts...) key. The tracking API is different.

Also, if you want to add event data, apparently you absolutely need to add a random unique ID. I struggled to find this as their docs are not super clear about it. So the body should look like something like this:

body: jsonEncode(<String, dynamic>{
      'eventdata': {
                     id:"123456",
                     data: {
                             event_data1: value1,
                             event_data2: value2,

                           }
                   }
      'email': example@mail.com,
      'event': eventName
    }),
Khalid B
  • 21
  • 2