Hi,
I configured a webhook to send an event (account created) from Amplitude to a Marketing Cloud data extention. But I can't manage to insert the records in my data extention.
Configuration on Amplitude is ok as the events are successfully received in the webhook.
I have the following payload :
{
<#if input.user_id??>
"EventDefinitionKey": "APIEvent-de4d30ac-5191-b5c2-efb2-a533cd294569",
"grant_type": "client_credentials",
"client_id": "ltr641qcp13eho9f38rip3uw",
"client_secret": "VFGRgkC51ojeM6tByQDrbCQo",
"external_id" : "${input.user_id}",
</#if>
"name" : "${input.event_type}",
"time" : "${input.event_time}",
"email_root" : "${input.user_properties.email!}",
"properties" : {
"email" : "${input.user_properties.email!}"
}
}
And I created a code resource in SFMC to insert the events records :
<script runat="server" language="javascript">
Platform.Load("Core", "1");
var jsonpost = Platform.Request.GetPostData();
var json = Platform.Function.ParseJSON(jsonpost);
var eventDefinitionKey = json.EventDefinitionKey;
var grantType = json.grant_type;
var clientId = json.client_id;
var clientSecret = json.client_secret;
var externalId = json.external_id;
var name = json.name;
var time = json.time;
var emailRoot = json.email_root;
var email = json.properties.email;
var dataExtensionName = "TestAmplitudeWebhook";
var deObj = {
"CustomerKey": dataExtensionName,
"Name": dataExtensionName,
"keys": [{
"Name": "external_id",
"Value": externalId
}],
"values": [{
"Name": "name",
"Value": name
},{
"Name": "time",
"Value": time
},{
"Name": "email",
"Value": email
}]
};
var data = [deObj];
var result = Platform.Function.InsertData(data, "Overwrite");
</script>
Did someone ever faced a similar issue ?