The Problem:
As per the current flow of Zoho Marketing Automation’s (MA) native integration with Zoho CRM, only one record per unique email address can be synced to MA. Even if multiple records exist in Zoho CRM for the same email address , each representing a separate product purchase , only one of those records is reflected in Zoho MA.
As a result, when a customer buys multiple products, and multiple records are created in Zoho CRM to track each purchase under the same email, only a single record is synced to MA. This behaviour makes it difficult to assign that synced record to multiple product-based segments in Zoho MA unless all relevant product purchase data is consolidated into that one synced record.
Let’s consider a scenario where you’ve created product-specific segments in Zoho MA such as “Pen Segment,” “Glue Segment,” “Pencil Segment,” etc , with specific criteria for each. When a record meets a segment’s conditions, it is automatically added and becomes eligible to receive targeted product campaigns.
While this setup works effectively when different product purchases are captured in separate synced records, it breaks down when only one record per email is synced. That’s because :
Therefore, for a single synced record to be included in multiple segments, it must simultaneously meet the criteria for all relevant product segments. This requires that all product purchase data be consolidated into one Zoho MA record, using fields (e.g., product checkboxes) that Zoho MA can use for segmentation.
By structuring the Zoho CRM record this way, the contact can be added to multiple Zoho MA segments and receive campaigns related to each product they’ve purchased.
The Solution:
This solution enables adding a single record to multiple Zoho Marketing Automation (MA) segments by following these steps :
Creating two custom modules in Zoho CRM :
Main Module (Purchase) : Stores one record per customer. This is the module that will be synced with Zoho MA to update values and sync record from Zoho CRM.
Duplicate Module (Purchase_Log) : Stores one record for each individual product purchase.
Creating identical checkbox fields (one for each product) in both modules to track purchases at the product level as well as in Zoho MA to capture the values synced from Zoho CRM.
Triggering a workflow with a custom function whenever a new product purchase is logged manually in the Purchase_Log module.
Using the custom function to update or create the corresponding customer record in the Main Module, selecting the appropriate product checkboxes based on the logged purchase.
Setting up synchronisation from the Main Module (Purchase) to Zoho MA :
Creating product-specific segments in Zoho MA :
How It Works:
Let’s say your business sells 5 products : Pen, Pencil, Rubber, Scale, and Glue.
Step-by-Step Example :
Step 1 : Bill buys Glue (first-time customer)
A record is manually created in the Duplicate Module (Purchase_Log) with only the "Glue" checkbox selected.
Note : Each product has a corresponding checkbox field in both the Purchase_Log and Purchase modules. When a new record is created for a purchase, the relevant product checkbox is selected by the user during creation of the record.
Upon creation of this record in the Purchase_Log module, a workflow is triggered, executing a custom function.
The custom function checks whether a record already exists for the name Bill in the Main Module (Purchase) :
Since the Main Module is synced with Zoho MA, this newly created record is synced to MA.
The data from the Zoho CRM record’s checkbox field is mapped to a corresponding custom field in Zoho Marketing Automation (e.g., "Glue_Selected"). The native sync automatically updates the value of this custom field in MA to reflect the selection in the Zoho CRM record.
Assuming a "Glue Segment" exists in Zoho MA with criteria based on the custom field (e.g., "Glue_Selected" is set to TRUE), Bill’s record will be added to the Glue Segment, as the condition is met. This is because the custom field in MA is updated via the native sync to match the selected checkbox value from the corresponding Zoho CRM record.
Step 2 : Bill buys Pen (returning customer)
- A new record is again manually created in the Purchase_Log module, this time with the "Pen" checkbox selected.
- The same workflow is triggered, running the custom function again.
- The function checks for an existing record in the Main Module for Bill :
- This time, Bill’s record is found, so the function simply updates the existing record to also select "Pen" check box = true.
- As the Main Module is already synced with MA, the record updates new checkbox value as well in the MA record. Now, the MA record for Bill has both :
"Glue" = true
"Pen" = true
- Assuming a "Pen Segment" exists in Zoho MA as well with criteria based on the custom field (e.g., "Pen_Selected" is set to TRUE), Bill’s record will be added to the Glue Segment, as the condition is met. This is because the custom field in Zoho MA is updated via the native sync to match the selected checkbox value from the corresponding Zoho CRM record.
Outcome :
Bill's single record in Zoho MA now qualifies for both the Glue and Pen segment criteria, allowing it to be included in two separate Zoho MA segments. As a result, he will receive campaigns related to both products he has purchased.
Prerequisites
To set up this workaround successfully, please ensure the following prerequisites are available for the user implementing the setup :
Zoho CRM :
Zoho Marketing Automation :
Setup Instructions :
Step 1 : Zoho CRM Setup
Create Two Custom Modules by navigating to Zoho CRM → Setup → Customisation → Modules and Fields → Create new module
Main Module (Purchase) : To store one consolidated record per customer, which is synced with Zoho MA.
Duplicate Module (Purchase_Log) : To store one unique record per product purchase.
Add individual checkbox fields for each product in both the custom module's layout (e.g., Pen, Pencil, Glue, Rubber, Scale) by navigating to Zoho CRM → Setup → Customisation → Modules and Fields → Choose the created custom module → Choose the respective layout → Drag and drop the checkbox field from the field palette on the left for each of the products sold into the layout → Name each checkbox based on the product name.
Step 2 : Workflow and Custom Function Setup
Kindly navigate to :
Zoho CRM → Setup → Automation → Workflow Rules → Create Rule → Select the duplicate module created (Purchase_Log) → Choose "On Create" as the execution trigger → Specify conditions if any → Under Instant Actions, select Function → + New Function → Write Your Own → Enter the Function Name and Display Name → Click Create → Copy and paste the below attached code
void automation.Marketingautomation(Int Id,String name)
{
purchaseA = zoho.crm.getRecordById("Purchase_A",Id);
email = purchaseA.get("Email");
pen = purchaseA.get("Pen");
pencil = purchaseA.get("Pencil");
glue = purchaseA.get("Glue");
rubber = purchaseA.get("Rubber");
scale = purchaseA.get("Scale");
purchase = zoho.crm.searchRecords("Purchase","Name:equals:" + name);
if(purchase.size() > 0)
{
for each rec in purchase
{
mp = Map();
if(rec.get("Pen") == False)
{
mp.put("Pen",pen);
}
if(rec.get("Pencil") == False)
{
mp.put("Pencil",pencil);
}
if(rec.get("Glue") == False)
{
mp.put("Glue",glue);
}
if(rec.get("Rubber") == False)
{
mp.put("Rubber",rubber);
}
if(rec.get("Scale") == False)
{
mp.put("Scale",scale);
}
info "mp::: " + mp;
upd = zoho.crm.updateRecord("Purchase",rec.get("id"),mp);
info upd;
}
}
else
{
mp = Map();
mp.put("Pen",pen);
mp.put("Pencil",pencil);
mp.put("Glue",glue);
mp.put("Rubber",rubber);
mp.put("Scale",scale);
mp.put("Name",name);
mp.put("Email",email);
info "mp : " + mp;
crt = zoho.crm.createRecord("Purchase",mp);
info "crt : " + crt;
}
}
Replace the respective module and field API names accordingly in the code :
a) In line 1 , replace "Purchase_A" with the custom Duplicate Module API Name created in Zoho CRM.
b) In line 4 to 9 , replace , "Email", "Pen", "Pencil" , "Glue" , "Rubber" , "Scale" with the Email field API Name of the Duplicate Module , Check Box fields API Names , created for your products with in the Duplicate Module.
c) In line 10 , replace "Purchase" with the API Name of the Main Module that will be synced with Zoho MA.
d) In the lines , 16 , 18 , 20 , 22 , 24 , 26 , 28 , 30 , 32 , 34 replace with the custom product check box field API Names present in the Main Module.
e) In the line 37 , update "Purchase" with the Main Module API Name.
f) In lines 44 - 49 , replace , "Pen", "Pencil" , "Glue" , "Rubber" , "Scale", "Name" , "Email" with the check box field API name , Name field API name , Email field API name , present with in the Main Module.
g) In line 52 , replace "Purchase" with the API Name of the Main Module.
Click on edit arguments ->
a) Click on + option, type # symbol in the right side input box, choose the Duplicate Module name and choose the Duplicate Module Id and name it as “Id” in the left side input box
b) Click on + option, type # symbol in the right side input box, choose the Duplicate Module and choose Duplicate Module Name field and name it as “name” in the left side input box
c) Click on save -> Save the workflow rule
Step 3 : Set Up Segments and Field Mapping in Zoho Marketing Automation :
From Zoho Marketing Automation, navigate to Setup → Apps → Zoho CRM → New Sync. In the Sync Setup, under Zoho CRM Module to Sync, select Custom Module, choose the Main Module, and click Next.
If you are setting up the sync between Zoho CRM and Zoho Marketing Automation for the first time, follow the steps below :
Setup → Apps → Connect App → Choose Zoho CRM → Click on Connect → Select your Zoho CRM organisation (in which the above modules are created) → Click Integrate. In the Sync Setup, under Zoho CRM Module to Sync, select Custom Module, choose the Main Module, and click Next.
- Once the Map Fields section opens, under Zoho CRM Fields, select the checkbox fields from the Main Module. Then, under Zoho Marketing Automation Fields, click the dropdown and select the option to add new fields in Zoho MA.
- Create a Zoho MA field with relevant names for each checkbox field (e.g., "Glue_Selected" as mentioned in the above examples), and map it to the corresponding checkbox field from Zoho CRM’s Main Module.
- Repeat this process for all checkbox fields in the Main Module by creating appropriately named fields in Zoho MA and mapping them accordingly. This will ensure that the values of checkbox fields from Zoho CRM are properly mapped and synced into the corresponding fields in Zoho MA.
Segment Creation in Zoho Marketing Automation :
- Create individual segments for each product by navigating to the segments option under the contact section .
- Define the segment criteria based on the new fields created during the field mapped from Zoho CRM main module (e.g., you would have mapped the product check box ( eg "Glue" ) , value from the main module to a new field created during the field mapping in Zoho MA ( eg "Glue_Selected" ) with the criteria as "Is true"
Final Result
Summary :
By consolidating product purchases using checkbox fields within a single Zoho CRM record, and syncing that record with Zoho Marketing Automation, businesses can bypass the limitation of one record per email and still include a customer in multiple product-specific segments. This enables precise targeting for campaigns based on complete purchase history, even when multiple purchases are made over time.
Custom Solution Created by Hiruthik | Zoho Partner Support.