CustomFit Dashboard
  • Getting Started
    • Installing CustomFit Code Snippet
      • Installing the code snippet on Webflow
      • Installing the code snippet on Wordpress
      • Installing the code snippet on Wix
      • Installing the code snippet on Shopify
      • Installing the code snippet on Unbounce
  • Account Setup
    • Configuring Account Users
    • Add Users and Assign Roles
    • Configuring Subdomains
    • Configuring Traffic Blocking
  • Experience
    • How to create an A/B test
    • How to create a Split URL test
    • How to create an AI Conversion Optimize experience
    • How to create an Outbound Experience
    • Creating an Experience
    • Experience Page Paths
    • Experience Targeting
    • Visual editor
    • Experience Goals
    • Experience Insights
    • Experience Settings
    • Experience Dashboard
    • Experience FAQs
  • Visual Editor
    • Overview
    • App Bar
    • Editor Palette
    • Toolbar
    • Popups
  • ABM
  • Audience Segments
    • Geo Location
    • Technology
    • UTM Parameters
    • Visitor Attributes
    • Salesforce Attributes
    • HubSpot Attributes
    • Kickfire Attributes
    • Visitor Behavior
      • Page event
      • Click event
      • Track event
  • Integrations
    • GA4 Integration
    • GA4 Integration via GTM
    • Microsoft Clarity Integration
    • Hotjar Integration
    • Clearbit Integration
    • 6sense Integration
    • Segment Integration
    • Mixpanel Integration
    • Amplitude Integration
    • Heap Integration
    • Salesforce
      • Connected App
      • Apex Class
      • Apex Triggers
      • Remote Site Settings
    • Kickfire
    • HubSpot
    • Slack
  • Split URL Testing
  • Reports
    • Create Report
    • Configure Targets
    • Configure Goals
  • Overview of Reports
  • Segments
    • Creating a Segment
    • Segment Rules
  • Dashboard
    • Analytics
  • Install the CustomFit snippet
  • Event Analyzer
    • Creating an Event
    • Forward Custom Events from GTM to CustomFit
    • Event Insights
    • Event Properties
    • Property Insights
  • Change Log
  • Frequently Asked Questions
    • CustomFit JS Script
Powered by GitBook
On this page

Was this helpful?

  1. Integrations
  2. Salesforce

Apex Class

PreviousConnected AppNextApex Triggers

Last updated 1 year ago

Was this helpful?

You can know more about Apex class . To Create an Apex Class

  • Click on settings icon

  • Then click on Setup option from the dropdown

  • Search for Apex Classes option and click on it

  • Click on New button

  • Copy and paste the below code snippet. The code snippet checks the Salesforce data and if there is any change/update in the customer information then it updates to CustomFit

public class CustomFitWebHook {
    
  public static String jsonContent(List<Object> triggerNew, List<Object> triggerOld) {
    String newObjects = '[]';
    if (triggerNew != null) {
      newObjects = JSON.serialize(triggerNew);
    }
    String oldObjects = '[]';
    if (triggerOld != null) {
      oldObjects = JSON.serialize(triggerOld);
    }
    String userId = JSON.serialize(UserInfo.getUserId());
    String instanceURL = JSON.serialize(URL.getOrgDomainUrl().toExternalForm());


    String content = '{"new": ' + newObjects + ', "old": ' + oldObjects + ', "userId": ' + userId + ', "instanceURL": ' + instanceURL + '}';
    return content;
  }
  @future(callout=true) public static void callout(String content) {
    Http h = new Http();
    HttpRequest req = new HttpRequest();
    req.setEndpoint('https://api.customfit.ai/v1/salesforce/webhooks');
    req.setMethod('POST');
    req.setHeader('Content-Type', 'application/json');
    req.setBody(content);
    h.send(req);
  }
}
  • Click on Save button

here