Introduction
In this support article, you can find some simple, common, integration examples, to serve as inspiration.
While simple queries, if you combine the different ideas, we're sure you'll be able to find your use case!
If you think something is missing, please feel free to let us know!
Table of Contents
Pull & Flag Examples
Testing if data enters CustomerGauge correctly
In this example we'll pull a single record, to ensure that all the data enters CustomerGauge correctly.
For this example, we'll ignore the flag — look at the example below for a Flag use case.
Pull query:
SELECT
Id,
FirstName,
LastName,
FROM Contact
WHERE Id IN ("XXX")
Replace XXX with the Id value of the Contact you'd like to test with.
Pull mapping:
{
"number_customer": "{Id}",
"first_name": "{FirstName}",
"last_name": "{LastName}",
"email": "{Email}"
}
Send a survey to Contacts that haven't been surveyed yet
In this example, we look at pulling some Contact data, and also preventing from pulling the same Contact again.
Pull query:
SELECT
Id,
FirstName,
LastName,
FROM Contact
WHERE Pulled_from_CG__c != true
Pull mapping:
{
"number_customer": "{Id}",
"first_name": "{FirstName}",
"last_name": "{LastName}",
"email": "{Email}"
}
Flag mapping:
[
{
"object": "Contact",
"id": "{number_customer}",
"fields": {
"Pulled_from_CG__c": "true"
}
}
]
Getting additional Account data for reporting purposes
In this example we'll be pulling information from both the Contact and Account objects in Salesforce.
Note that we don't want to over-survey the same Contact, so we'll also flag the pulled Contact to prevent pulling duplicates.
Pull query:
SELECT
Id,
FirstName,
LastName,
Email,
Account.Name,
Account.Id,
Account.Owner.Email,
Account.Owner.Name
FROM Contact
WHERE Pulled_from_CG__c != true
Contact is the main object, and we're pulling additional data from Account, as well as the Account's Owner.
Pull mapping:
{
"number_customer": "{Contact.Id}",
"first_name": "{Contact.FirstName}",
"last_name": "{Contact.LastName}",
"email": "{Contact.Email}",
"segment_j": "{Contact.Owner.Name}",
"segment_i": "{Id}",
"company": "{Account.Name}",
"company_number": "{Account.Id}",
"agent_email_contact": "{Account.Owner.Email}",
"agent": "{Account.Owner.Name}"
}
Flag mapping:
[
{
"object": "Contact",
"id": "{number_customer}",
"fields": {
"Pulled_from_CG__c": "true"
}
}
]
We flag the pulled Contact, so we don't pull them again
Send a survey when a Case in Salesforce gets closed
In this example we'll pull from the Case object in Salesforce — assuming that closing Cases would need to result in a survey.
Note that we don't want to over-survey the same Contact, so we'll also flag the pulled Contact to prevent pulling duplicates.
Pull query:
SELECT
Contact.Id,
Contact.FirstName,
Contact.LastName,
Contact.Email,
Contact.Owner.Name,
Id
FROM Case
WHERE Status = 'Closed' AND Contact.Pulled_from_CG__c != true
Status is a field in the Case object so it does not need a "Case." prefix (Case is the main object). Pulled_from_CG__c on the other hand comes from the Contact object, and Contact is not the main object we're pulling from.
Pull mapping:
{
"number_customer": "{Contact.Id}",
"first_name": "{Contact.FirstName}",
"last_name": "{Contact.LastName}",
"email": "{Contact.Email}",
"segment_j": "{Contact.Owner.Name}",
"segment_i": "{Id}"
}
Flag mapping:
[
{
"object": "Contact",
"id": "{number_customer}",
"fields": {
"Pulled_from_CG__c": "true"
}
}
]
Send a Win/Loss survey when an Opportunity gets closed in Salesforce
In this example, we'll pull data from Salesforce to send out Win/Loss surveys when Opportunities get closed.
We'll also flag the Contact, so that we do not over-survey them.
This setup requires the Opportunity to have Contact Roles against it.
Pull query:
SELECT
Contact.Id,
Contact.FirstName,
Contact.LastName,
Contact.Email,
Opportunity.Owner.Name,
Opportunity.Owner.Email,
Id
FROM OpportunityContactRole WHERE ( Opportunity.StageName = 'Closed Won' OR Opportunity.StageName = 'Closed Lost' ) AND Contact.Pulled_from_CG__c != false
Opportunity and Contact are normally not connected, but by using the Contact Roles as the main object, we're able to fetch data from both the Contact and Opportunity Objects.
Flag mapping:
{
"number_customer": "{Contact.Id}",
"first_name": "{Contact.FirstName}",
"last_name": "{Contact.LastName}",
"email": "{Contact.Email}",
"agent": "{Opportunity.Owner.Name}",
"agent_email_contact": "{Opportunity.Owner.Email}"
}
Pull mapping:
[
{
"object": "Contact",
"id": "{number_customer}",
"fields": {
"Pulled_from_CG__c": "true"
}
}
]
Push Examples
Store survey results in a custom object
In this example, we will store CustomerGauge survey results in a custom Salesforce object.
Assume we've created the following custom object in Salesforce;
Object Name: CGSurveyResults__c
Field Name | Field Type |
CG_ID__c | Text(11) |
ContactId__c | Lookup(Contact) |
Date_Survey_Completed__c | Date/Time |
Date_Survey_Sent__c | Date/Time |
Follow_Up_Required__c | Checkbox |
NPS_Score__c | Number(2, 0) |
CES_Score__c | Number(2, 0) |
Survey_Comment__c | Long Text Area(32768) |
Survey_Drivers__c | Long Text Area(32768) |
AccountManagerId__c | Lookup(User, Group) |
Touchpoint__c | Text(255) |
We'd then map all the CustomerGauge fields as such;
Push mapping:
[
{
"object": "CGSurveyResults__c",
"method": "insert",
"fields": {
"Name":"CXM Survey",
"CG_ID__c":"{number_customergauge}",
"ContactId__c":"{number_customer}",
"Date_Survey_Completed__c":"{date_form_completed}",
"Date_Survey_Sent__c":"{date_email_sent}",
"Follow_Up_Required__c":"{answer_required}",
"NPS_Score__c":"{q1}",
"CES_Score__c":"{additional_question_1}",
"Survey_Comment__c":"{comment}",
"Drivers__c":"{selfselect_list}",
"AccountManagerId__c":"{segment_a}",
"Touchpoint__c":"{segment_b}"
}
}
]
We will now be storing all survey responses as they come in, in its own Salesforce object.
We maintain links to both Contacts and Account Owners, allowing Salesforce users to quickly drill into them.
Update Contact with Last Survey Completion Date
In this example, we'll update a contact record with the Last Survey Completion date.
To accommodate this, we've created the custom field Date_Last_Survey_Completed__c in the Contact object.
[
{
"object": "Contact",
"method": "update",
"Id":"{number_customer}",
"fields": {
"Date_Last_Survey_Completed__c":"{date_form_completed}"
}
}
]
Now, every time a survey gets completed, the matching Contact record gets updated with the date.
We can then use this date in our Pull Query to make sure we don't survey someone that recently completed a survey.
Create a Salesforce Case upon Survey completion
In this example, we will create a Salesforce Case whenever a survey gets completed.
Because we want to have all the relevant data at hand when working on the case, we'll add a few custom fields to the Case object, like so;
Object Name: Case
Field Name | Field Type |
CG_ID__c | Text(11) |
ContactId__c | Lookup(Contact) |
Date_Survey_Completed__c | Date/Time |
Date_Survey_Sent__c | Date/Time |
Follow_Up_Required__c | Checkbox |
NPS_Score__c | Number(2, 0) |
CES_Score__c | Number(2, 0) |
Survey_Comment__c | Long Text Area(32768) |
Survey_Drivers__c | Long Text Area(32768) |
AccountManagerId__c | Lookup(User, Group) |
Touchpoint__c | Text(255) |
We'd then map all the CustomerGauge fields as such;
[
{
"object": "Case",
"method": "insert",
"fields": {
"Name":"Survey Completed",
"CG_ID__c":"{number_customergauge}",
"ContactId":"{number_customer}",
"Date_Survey_Completed__c":"{date_form_completed}",
"Date_Survey_Sent__c":"{date_email_sent}",
"Follow_Up_Required__c":"{answer_required}",
"NPS_Score__c":"{q1}",
"CES_Score__c":"{additional_question_1}",
"Survey_Comment__c":"{comment}",
"Drivers__c":"{selfselect_list}",
"OwnerId":"{segment_a}",
"Touchpoint__c":"{segment_b}"
}
}
]
Add a Deep Link to CustomerGauge in Salesforce
In this example, we will create a Salesforce Case whenever a survey gets completed, providing a deep link to the related Response in CustomerGauge. We'll only focus on the deep link part; please see the other examples to expand the fields.
Providing "{categorize_url}" will populate our custom field with the URL of the related Customer Details Page.
[
{
"object": "Case",
"method": "insert",
"fields": {
"CustomerGaugeResponseUrl__c":"{categorize_url}"
}
}
]