Skip to content

troysellers/salesforce-event-source

Repository files navigation

Segment Salesforce Event Source

This is a simple Salesforce CLI project that shows how you can send events to the Segment HTTP API from within a Salesforce org.

First, get yourself a Salesforce developer account. The Salesforce CLI is going to be your next stop..

Once your development environment is configured

Then, setup a Segment HTTP API source

Example of calling .track() using anonymous apex

SegmentTrackEvent evt = new SegmentTrackEvent();
evt.userId = '019mr8mf4r';
evt.event = 'Item Purchased';
evt.addCustomProperty('name', 'Leap to Conclusions Mat');
evt.addCustomProperty('revenue', '14.99');
        
SegmentContext context = new SegmentContext();
context.ip = '24.5.68.47';

evt.timestamp = DateTime.now();

SegmentUtil util = new SegmentUtil('<YOUR SEGMENT WRITE KEY');
util.track(evt); 

Segment API Methods implemented:

  • track()
  • page()
  • identify()

About

Simple example of how to call the Segment HTTP API from within your Salesforce org.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages