Salesforce Integration: Custom Apex Triggers

If you don't want to use our Salesforce connector or you need to set up a quick integration without going through your IT team, you can setup custom Apex Triggers to push new CampaignMember entries to your InEvent event.

To accomplish this task, we have created two Apex classes:


This is an Apex Trigger that runs every time a new CampaignMember entry is added to your Salesforce account. Since the trigger is universal, we need to filter only entries that are added to our Campaign, and that is defined by our SF_CAMPAIGN_ID variable. We also need to define what event we want to push these leads to, and that is defined by our IN_EVENT_ID variable. In this example we have the following values:

  • SF_CAMPAIGN_ID = '7015G000000SZIUQA4' this is our Campaign on Salesforce;
  • IN_EVENT_ID = '69442441' this is our Event on InEvent;

Here is the full source code for this trigger:

trigger PushLeadToInEventTrigger on CampaignMember (after insert) {
// Your settings variables
String SF_CAMPAIGN_ID = '7015G000000SZIUQA4'; // Your Salesforce CampaignId
String IN_EVENT_ID = '69442441'; // Your InEvent eventID

for (CampaignMember cm: {
// Skip other campaigns
if (cm.CampaignId != SF_CAMPAIGN_ID) continue;

// If you need more fields or custom fields, you can check our API documentation
Map<String, String> body = new Map<String, String>();
body.put('firstName', cm.FirstName);
body.put('lastName', cm.LastName);
body.put('username', cm.Email);
body.put('email', cm.Email);
body.put('password', ''); // leave empty if using block password tool
body.put('role', cm.Title);
body.put('company', cm.CompanyOrAccount);
body.put('telephone', cm.Phone);
body.put('feedbackContent', '[]'); // custom fields would go here (required, even if empty, expects a serialized JSON)

PushLeadToInEvent.push(IN_EVENT_ID, body);

// MIT License


This class has the future method that pushes the contents received from our Apex Trigger to InEvent. You only need to make changes to it if you want to add extra fields or if you want to sync to a different endpoint on InEvent.

This code creates a new Attendee on InEvent, so it will consume one registration credit per submission.

Here is the full source code for this class:

public class PushLeadToInEvent {
@future (callout=true)
public static void push(String eventID, Map<String, String> body) {

// Our HTTP request configuration
Http http = new Http();
HttpRequest request = new HttpRequest();
request.setHeader('Content-Type', 'application/x-www-form-urlencoded;charset=UTF-8');

// Our query string builder
Map<String, String> query = new Map<String, String>();
query.put('action', 'form.respondRegistration');
query.put('version', '2');
query.put('eventID', eventID);

String cQuery = '';
for (String key : query.keySet()) {
if (String.isEmpty(cQuery)) {
cQuery += '?' + key + '=' + query.get(key);
} else {
cQuery += '&' + key + '=' + query.get(key);

String cBody = '';
for (String key : body.keySet()) {
String val = body.get(key);
if (val == null) val = '';
val = EncodingUtil.urlEncode(val, 'UTF-8');

if (String.isEmpty(cBody)) {
cBody += key + '=' + val;
} else {
cBody += '&' + key + '=' + val;

request.setEndpoint('' + cQuery);

HttpResponse response = http.send(request);

System.debug('Calling [POST] ' + '' + cQuery);
System.debug('Body: ' + cBody);

// Parse the JSON response
if (response.getStatusCode() >= 400) {
System.debug('The status code returned was not expected: ' +
response.getStatusCode() + ' ' + response.getStatus() + ' ' + response.getBody());
} else {

// MIT License

How Did We Do?