## How We Work Together

Salesforce Marketing Cloud is a customer data platform that allows you to trigger real-time messaging and enter users into marketing “Journeys” based on Pilgrim events triggered by your users. You can also set up a Data Extension within Salesforce which allows Pilgrim events to feed data into the Data Extension, effectively creating a database of Visits and Geofences for each user that can be used to create segments, track user visits to specific POIs, etc.

## Examples of What You Can Do

- Create marketing “Journeys” to customize in-app interactions with your users.
- Trigger real-time messaging based on Visit and Geofence events.

## Example JSON Payloads

Visits DepartureVisits ArrivalGeofence PresenceGeofence ExitGeofence Enter

```json
{
    "EventDefinitionKey": "pilgrimArrivalEntrySource",
    "ContactKey": "{String}",
    "Data": {
        "visitType": "departure",
        "confidence": "{ConfidenceLevel}",
        "lat": "{lat}",
        "lng": "{long}",
        "locationType": "venue",
        "visitId": "{VisitID}",
        "timestamp": "{Timestamp}",
        "venueName": "{VenueName}",
        "venueId": "{VenueID}",
        "primaryCategoryName": "{PrimaryCategoryName}",
        "primaryCategoryId": "{PrimaryCategoryID}",
        "address": "{Address}",
        "crossStreet": "{Cross Street}",
        "city": "{CityName}",
        "state": "{StateCode}",
        "zipCode": "{ZipCode}",
        "country": "{CountryCode}",
        "ContactKey": "{String}",
        "userId": "{String}"
    }
}
```

```json
{
    "EventDefinitionKey": "pilgrimArrivalEntrySource",
    "ContactKey": "{String}",
    "Data": {
        "visitType": "arrival",
        "confidence": "{ConfidenceLevel}",
        "lat": "{lat}",
        "lng": "{long}",
        "locationType": "venue",
        "visitId": "{VisitID}",
        "timestamp": "{Timestamp}",
        "venueName": "{VenueName}",
        "venueId": "{VenueID}",
        "primaryCategoryName": "{PrimaryCategoryName}",
        "primaryCategoryId": "{PrimaryCategoryID}",
        "address": "{Address}",
        "crossStreet": "{Cross Street}",
        "city": "{CityName}",
        "state": "{StateCode}",
        "zipCode": "{ZipCode}",
        "country": "{CountryCode}",
        "ContactKey": "{String}",
        "userId": "{String}"
    }
}
```

```json
{
    "EventDefinitionKey": "pilgrimArrivalEntrySource",
    "ContactKey": "{String}",
    "Data": {
        "geofenceEventType": "presence",
        "geofenceLat": "{Double}",
        "geofenceLng": "{Double}",
        "radius": "{Double}",
        "venueId": "{String}",
        "categoryIds": "{String}",
        "venueChainIds": "{String}",
        "partnerVenueId": "{String}",
        "eventLat": "{Double}",
        "eventLng": "{Double}",
        "geofenceId": "{String}",
        "geofenceName": "{String}",
        "geofenceProperties": {},
        "ContactKey": "{String}",
        "userId": "{String}"
    }
}
```

```json
{
    "EventDefinitionKey": "pilgrimArrivalEntrySource",
    "ContactKey": "{String}",
    "Data": {
        "geofenceEventType": "exit",
        "geofenceLat": "{Double}",
        "geofenceLng": "{Double}",
        "radius": "{Double}",
        "venueId": "{String}",
        "categoryIds": "{String}",
        "venueChainIds": "{String}",
        "partnerVenueId": "{String}",
        "eventLat": "{Double}",
        "eventLng": "{Double}",
        "geofenceId": "{String}",
        "geofenceName": "{String}",
        "geofenceProperties": {},
        "ContactKey": "{String}",
        "userId": "{String}"
    }
}
```

```json
{
    "userId": "{String}",
    "eventName": "geofenceEnter",
    "createdAt": 1646691428,
    "dataFields": {
        "geofenceEventType": "entrance",
        "geofenceLat": "{Double}",
        "geofenceLng": "{Double}",
        "radius": "{Double}",
        "venueId": "{String}",
        "categoryIds": "{String}",
        "venueChainIds": "{String}",
        "partnerVenueId": "{String}",
        "eventLat": "{Double}",
        "eventLng": "{Double}",
        "geofenceId": "{String}",
        "geofenceName": "{String}"
    }
}
```

## Integration Details

1. Make sure the [Pilgrim SDK](https://docs.foursquare.com/developer/docs/pilgrim-sdk/) is properly setup.
2. Optionally, set any user specific ID in using the `setUserId method` of `PilgrimUserInfo` in the Pilgrim SDK.
3. From your [Foursquare Pilgrim Console](https://foursquare.com/developers/apps/), [Enable Third Party Integrations](https://docs.foursquare.com/developer/docs/enable-third-party-integrations) and enter your SalesForce MC `Client ID`, `Client Secret` and `Event Definition Key`.
4. Once you have configured the Pilgrim Console, the Pilgrim SDK will automatically track location events and forward them to SalesForce MC.
