Uploading deals from a CRM
Uploading deals from a CRM
Overview
| Name | Description |
|---|---|
| Deal | A record in your CRM that moves through the stages of a sales funnel. |
| Contact | A customer record in your CRM. |
| Sales funnel | A sequence of stages that a deal moves through, from creation to successful completion or failure. |
| Stage | A step in the company's sales process. |
| Deal owners | The CRM user responsible for a specific deal. |
To analyze advertising performance through to closed deals and revenue, upload deal data from your CRM to CallGear.
You can use a built-in CRM integration, such as Bitrix24, amoCRM, or MIS Infoclinic, with the End-to-End Analytics feature enabled.
For any other CRM, use the API to build a custom integration.
To configure a custom CRM integration through the API:
-
Create the CRM structure in CallGear
-
Upload the structure of each sales funnel.
-
Upload the deal owners.
-
Upload the contacts.
-
Upload deal history.
-
Configure End-to-End Analytics.
-
Configure the fields required in analytics reports.
The following example shows how to upload a CRM structure and its related deal data.
| Example | Uploading deals and related CRM data |
|---|---|
| Description | Funnel name: "Main Funnel". Sales funnel stages: - Stage 1: "New Deal" - Stage 2: "Document Preparation" - Stage 3: "Prepayment Invoice" - Stage 4: "Final Invoice" - Successful stage: "Closed Won" - Failed stage: "Closed Lost" Funnel data: - 2 deal owners - 3 contacts - 3 deals: - Deal 1 moved through every stage and closed as won. - Deal 2 moved through the first stage and then closed as lost. - Deal 3 reached the "Prepayment Invoice" stage. Each deal is associated with a contact and a deal owner. |
1. Upload your CRM structure to CallGear
1.1 Create a sales funnel
| Method | "create.sales_funnel" |
|---|---|
| API version | — |
| Description | Creates a sales funnel and its stages. |
Available to: Agents and clients
The example uses stage-order values of 10, 20, 30, and 40. Leaving gaps makes it possible to add stages later without renumbering the entire funnel. For example, a new "Document Signing" stage between "Document Preparation" and "Prepayment Invoice" can use order 25.
Maximum stage order: 10,000.
Example request
{
"jsonrpc": "2.0",
"id": 1,
"method": "create.sales_funnel",
"params": {
"access_token": "${#Project#auth_prod_4735}",
"ext_id": "1",
"name": "Main Funnel",
"stages": {
"success": {
"ext_id": "1000",
"name": "Closed Won"
},
"failed": {
"ext_id": "10001",
"name": "Closed Lost"
},
"in_process": [
{
"ext_id": "1",
"name": "New Deal",
"order": 10
},
{
"ext_id": "2",
"name": "Document Preparation",
"order": 20
},
{
"ext_id": "3",
"name": "Prepayment Invoice",
"order": 30
},
{
"ext_id": "4",
"name": "Final Invoice",
"order": 40
}
]
}
}
}
The response returns the external ID of the created sales funnel.
Example response
{
"result": {
"metadata": {"limits": {
"minute_reset": 23,
"minute_remaining": 199,
"minute_limit": 200,
"day_reset": 35483,
"day_remaining": 3319,
"day_limit": 3500
}},
"data": {
"ext_id": "1"
}
},
"id": 1,
"jsonrpc": "2.0"
}
Verify the sales funnel structure
| Method | "get.sales_funnel" |
|---|---|
| API version | — |
| Description | Retrieves a list of sales funnels. |
Available to: Agents and clients
Example request
{
"jsonrpc":"2.0",
"id":"number",
"method":"get.sales_funnel",
"params":{
"access_token":"${#Project#auth_prod_4735}",
"filter":{
"field":"ext_id",
"operator":"=",
"value":"1"
}
}
}
Example response
{
"result": {
"metadata": {
"limits": {
"minute_reset": 39,
"minute_remaining": 199,
"minute_limit": 200,
"day_reset": 35139,
"day_remaining": 3305,
"day_limit": 3500
},
"total_items": 1
},
"data": [{
"ext_id": "1",
"name": "Main Funnel",
"stages": [
{
"stage_name": "New Deal",
"stage_ext_id": "1",
"stage_status": "in_process",
"stage_order": 10
},
{
"stage_name": "Document Preparation",
"stage_ext_id": "2",
"stage_status": "in_process",
"stage_order": 20
},
{
"stage_name": "Prepayment Invoice",
"stage_ext_id": "3",
"stage_status": "in_process",
"stage_order": 30
},
{
"stage_name": "Final Invoice",
"stage_ext_id": "4",
"stage_status": "in_process",
"stage_order": 40
},
{
"stage_name": "Closed Won",
"stage_ext_id": "1000",
"stage_status": "success",
"stage_order": 10010
},
{
"stage_name": "Closed Lost",
"stage_ext_id": "10001",
"stage_status": "failed",
"stage_order": 10020
}
]
}]
},
"id": "number",
"jsonrpc": "2.0"
}
To rename the sales funnel, use update.sales_funnel. To update its stages, use update.sales_funnel_stages.
1.2 Create deal owners
Skip this section if you do not need to analyze advertising campaign performance by deal owner.
The following examples create two deal owners.
| Method | "create.deal_employees" |
|---|---|
| API version | — |
| Description | Creates a deal owner. |
Available to: Agents and clients
(See the full create.deal_employees reference in the "Deal owners" section below.)
Example request 1
{
"jsonrpc": "2.0",
"id": "1",
"method": "create.deal_employees",
"params": {
"access_token":"${#Project#auth_prod_4735}",
"ext_id": "EID_0007",
"name": "Ivanov"
}
}
Example request 2
{
"jsonrpc": "2.0",
"id": "2",
"method": "create.deal_employees",
"params": {
"access_token":"${#Project#auth_prod_4735}",
"ext_id": "EBdfID_0008",
"name": "Sidorov"
}
}
1.3 Create deal contacts
| Method | "create.deal_contacts" |
|---|---|
| API version | — |
| Description | Creates a deal contact. |
Available to: Agents and clients
Example:
The CRM contains three contacts with the external IDs CID_0001, CID_0002, and CID_0003.
| ID | Name | Phone | |
|---|---|---|---|
| CID_0001 | Oleg Ivanov | 79000000000, 79000000001 | test@example.com, test2@example.com |
| CID_0002 | Petr Petrov | 79000000003 | test3@example.com |
| CID_0003 | New Customer | 79000000004 |
Example request
{
"jsonrpc": "2.0",
"id": 1,
"method": "create.deal_contacts",
"params": {
"access_token": "${#Project#auth_prod_4735}",
"contacts": [
{
"ext_id": "CID_0001",
"name": "Oleg Ivanov",
"created_date_time": "2019-08-02 21:00:01",
"phone_numbers": [
"79000000000",
"79000000001"
],
"emails": [
"test@example.com",
"test2@example.com"
]
},
{
"ext_id": "CID_0002",
"name": "Petr Petrov",
"created_date_time": "2019-08-03 12:15:00",
"phone_numbers": [
"79000000003"
],
"emails": [
"test3@example.com"
]
},
{
"ext_id": "CID_0003",
"name": "New Customer",
"created_date_time": "2019-08-10 10:40:50",
"phone_numbers": [
"79000000004"
]
}
]
}
}
2. Upload deal history
For accurate analytics, upload every stage a deal has passed through, not only its current stage.
You can upload the history in either of the following ways:
-
Use CRM triggers to upload the deal whenever one of these events occurs:
-
The deal is created.
-
The deal moves to another stage.
-
The contact, deal owner, or revenue changes.
-
Periodically upload the complete history for all deals, for example hourly, daily, or weekly. Include every completed stage and the time when the deal entered it.
The End-to-End Analytics report displays the complete uploaded history for each deal, including every stage the deal has passed through.
If an intermediate stage is missing from the uploaded history, the system creates it automatically with is_generated = true so that reports remain consistent. Stage metrics include all deals that passed through the stage.
There are no separate create and update methods for deals. The first uploaded record creates the deal; subsequent records with the same ext_id update its history.
Upload a deal that moved through every stage and closed as won
Example request
{
"jsonrpc": "2.0",
"id": 1,
"method": "upload.deals_history",
"params": {
"access_token": "${#Project#auth}",
"deals": [
{
"ext_id": "DID_0001",
"name": "Annihilator Cannon Sale",
"created_date_time": "2019-08-15 07:07:00",
"modified_date_time": "2019-08-15 07:07:00",
"modified_stage_date_time": "2019-08-15 07:07:00",
"contact_ext_ids": [
"CID_0001"
],
"main_contact_ext_id": "CID_0001",
"employee_ext_id": "EID_0001",
"sales_funnel_ext_id": "SFID_0001",
"stage_ext_id": "1",
"comments": "High-value deal"
},
{
"ext_id": "DID_0001",
"name": "Annihilator Cannon Sale",
"created_date_time": "2019-08-15 07:07:00",
"modified_date_time": "2019-08-16 07:07:00",
"modified_stage_date_time": "2019-08-16 07:07:00",
"contact_ext_ids": [
"CID_0001"
],
"main_contact_ext_id": "CID_0001",
"employee_ext_id": "EID_0002",
"sales_funnel_ext_id": "SFID_0001",
"revenue": 5000,
"stage_ext_id": "2",
"comments": "High-value deal"
},
{
"ext_id": "DID_0001",
"name": "Annihilator Cannon Sale",
"created_date_time": "2019-08-15 07:07:00",
"modified_date_time": "2019-08-17 07:07:00",
"modified_stage_date_time": "2019-08-17 07:07:00",
"contact_ext_ids": [
"CID_0001"
],
"main_contact_ext_id": "CID_0001",
"sales_funnel_ext_id": "SFID_0001",
"stage_ext_id": "3",
"comments": "High-value deal"
},
{
"ext_id": "DID_0001",
"name": "Annihilator Cannon Sale",
"created_date_time": "2019-08-15 07:07:00",
"modified_date_time": "2019-08-18 07:07:00",
"modified_stage_date_time": "2019-08-18 07:07:00",
"contact_ext_ids": [
"CID_0001"
],
"main_contact_ext_id": "CID_0001",
"sales_funnel_ext_id": "SFID_0001",
"stage_ext_id": "4",
"comments": "High-value deal"
},
{
"ext_id": "DID_0001",
"name": "Annihilator Cannon Sale",
"created_date_time": "2019-08-15 07:07:00",
"closed_date_time": "2019-08-19 10:07:00",
"modified_date_time": "2019-08-19 10:07:00",
"modified_stage_date_time": "2019-08-19 10:07:00",
"contact_ext_ids": [
"CID_0001"
],
"main_contact_ext_id": "CID_0001",
"sales_funnel_ext_id": "SFID_0001",
"stage_ext_id": "10000",
"comments": "High-value deal"
}
]
}
}
Upload a deal that moved from the first stage to closed as lost
Example request
{
"jsonrpc": "2.0",
"id": 1,
"method": "upload.deals_history",
"params": {
"access_token": "${#Project#auth}",
"deals": [
{
"ext_id": "DID_0002",
"name": "Puky Pukylino Balance Bike",
"created_date_time": "2019-08-15 07:07:00",
"modified_date_time": "2019-08-15 07:07:00",
"modified_stage_date_time": "2019-08-15 07:07:00",
"contact_ext_ids": [
"CID_0002"
],
"main_contact_ext_id": "CID_0002",
"employee_ext_id": "EID_0002",
"revenue": 4250,
"sales_funnel_ext_id": "SFID_0002",
"stage_ext_id": "1",
"comments": "High-value deal"
},
{
"ext_id": "DID_0002",
"name": "Puky Pukylino Balance Bike",
"created_date_time": "2019-08-15 07:07:00",
"closed_date_time": "2019-08-19 10:07:00",
"modified_date_time": "2019-08-19 10:07:00",
"modified_stage_date_time": "2019-08-19 10:07:00",
"contact_ext_ids": [
"CID_0002"
],
"main_contact_ext_id": "CID_0002",
"sales_funnel_ext_id": "SFID_0002",
"stage_ext_id": "10002",
"comments": "Does not support the required weight"
}
]
}
}
Upload a deal that reached the "Prepayment Invoice" stage
Example request
{
"jsonrpc": "2.0",
"id": 1,
"method": "upload.deals_history",
"params": {
"access_token": "${#Project#auth}",
"deals": [
{
"ext_id": "DID_0003",
"name": "Sony PlayStation 4 Slim 500 GB",
"created_date_time": "2019-08-15 07:07:00",
"modified_date_time": "2019-08-15 07:07:00",
"modified_stage_date_time": "2019-08-15 07:07:00",
"contact_ext_ids": [
"CID_0003"
],
"main_contact_ext_id": "CID_0003",
"employee_ext_id": "EID_0003",
"sales_funnel_ext_id": "SFID_0003",
"stage_ext_id": "1"
},
{
"ext_id": "DID_0003",
"name": "Sony PlayStation 4 Slim 500 GB",
"created_date_time": "2019-08-15 07:07:00",
"modified_date_time": "2019-08-16 07:07:00",
"modified_stage_date_time": "2019-08-16 07:07:00",
"contact_ext_ids": [
"CID_0003"
],
"main_contact_ext_id": "CID_0003",
"employee_ext_id": "EID_0002",
"sales_funnel_ext_id": "SFID_0003",
"revenue": 17350,
"stage_ext_id": "2"
},
{
"ext_id": "DID_0003",
"name": "Sony PlayStation 4 Slim 500 GB",
"created_date_time": "2019-08-15 07:07:00",
"modified_date_time": "2019-08-17 07:07:00",
"modified_stage_date_time": "2019-08-17 07:07:00",
"contact_ext_ids": [
"CID_0003"
],
"main_contact_ext_id": "CID_0003",
"sales_funnel_ext_id": "SFID_0003",
"stage_ext_id": "3",
"comments": "Awaiting payment"
}
]
}
}
3. Configure End-to-End Analytics.
In your CallGear account, open the Integrations section and connect the CRM through the "Other CRM" option.
4. Configure analytics reports
Select the data you need to display and analyze in your analytics reports.