Introduction
You have a website's page, or a CloudPage that has a form, this has a form and the user submits the Form and you want him to enter the Journey immediatly, receives a Welcome email and then take his own path into the Journey based on his/her reactions on the email, or let's take another scenarios, you have a big list of Customers and you want to push them into a Journey in real time from an external application, Event API and a Backend Programming Language will definetly help you at achieving this.
This tutorial is for developers that'll will deal with Marketers, so here, you'll basically learn how to push a contact you have into an existing Jounrey that has an API event as Entry Source
We'll create a Journey, with this API Event Entry Source, with an Email Activity for Testing Purposes, also a script to push a new contact into this Journey, and the result expected is receiving the email.
Use case is clear ? Great! Now let's get back to business
Prerequisites
You know how to get a REST API token, check this article
Demonstration
First Thing you'll have to do is creating your Journey inside Journey, then try to drap the Event Api as Entry Source to it
After that you'll have to create a new event after clicking on the EVENT API Entry source.
Now you have your Event Definition Key that you have to keep somewhere and Select a Sendable Data Extention, Our Contact that we'll push will be pushed into this Data Extention.
This how your Journey should look like at the end of all this
Now time for some coding, as already mentioned here, you'll have to get your access token first. This is your script for the token that you can put inside a JSON Resource, you can find more details on how this works in the article above.
After that you'll have to add this to the script below to add the contact to the Journey
I believe the script is well explained using comments.. but let's reexplain! In the eventPayload we define the data of our contact that we'll send to the API in the Data Property, as well as the event definition key we got in the beggining of the article in the EventDefinitionKey Property.
And that's the whole script
And that's it! Easy right ? If you follow the same steps, you'll be supposed to receive something as I did.. right! It is the email I set up in the Journey, I got it in my Inbox now..
Conclusion
The Fact that you're able to push a contact into your Journey using Event API is a fantastic thing, this is how you'll dive into Developer role, you'll be able to help clients that have SFMC to push their contact from their website using such scripts, but one important thing to know is that this script isn't that secure, also the payload data has to be dynamic. In order to make it secure maybe you'll have to add some custom credentials that are encrypted and decrypt them to make a verification, also the payload data is something that you can set up by getting your request body values. We'll check some of that very soon! Stay Tunned!!