We have had this questions asked a few times lately so thought it would be a great idea to post it here for others benefit.
How can I track campaign information in CRM from my online campaigns and report on UTM tracking details?
Below is what we have set up for other businesses who are using UTM Codes for all their campaigns. Follow the 4 steps below to set this up for your CRM:
1. Create Fields in CRM Leads Module
Add a field in the Leads module called 'Referrer URL' (URL field type).
Added a section in the Leads module called 'UTM - Campaign Details' and add these fields (Single Line field type):
- Campaign Name
- Campaign Source
- Campaign Medium
- Campaign Term
- Campaign Content
2. Create a Custom Function
Next you will need to configure a Custom Function that takes the UTM tracking details from the 'Referrer URL' and adds them to the UTM fields above in the Leads module. Here is the custom function code that you will need to also create in your CRM (to create a Custom Function go to CRM 'Settings' => 'Automations' => 'Actions' => 'Custom Functions' (on the top), then click 'Configure Function' button on the right):
Set this up for your Leads module.
Custom Function Name: Add UTM tracking details to Lead Fields
Argument Mapping - Name: leadId = Value: Lead Id
(copy and paste this code to your custom function. If you have set the Argument above exactly the same it should work for you)
getLeads = zoho.crm.v1.getRecordById("Leads",leadId);
referrerUrl = getLeads.get("Referrer URL");
urlVal = referrerUrl.indexOf("?");
customVariables = referrerUrl.substring(urlVal + 1);
utm_source = "";
utm_medium = "";
utm_campaign = "";
utm_term = "";
utm_content = "";
formMap = Map();
for each customVariablesArr in customVariables.toList("&")
var_s = getPrefix(customVariablesArr,"=");
val_s = getSuffix(customVariablesArr,"=");
if(var_s == "utm_source")
utm_source = val_s;
if(var_s == "utm_medium")
utm_medium = val_s;
if(var_s == "utm_campaign")
utm_campaign = val_s;
if(var_s == "utm_term")
utm_term = val_s;
if(var_s == "utm_content")
utm_content = val_s;
leadupdated = zoho.crm.v1.updateRecord("Leads",leadId.toString(),formMap);
3. Create a Workflow Rule to trigger the Custom Function
To run the above code a Workflow Rule needs to be created. We created a workflow rule WHEN a Lead is Created or is Edited to meet the condition:
Condition 1 - Referrer CONTAINS utm
Instant Action - (select the Function you created above)
4. Create a hidden field in your online forms for 'Referrer URL' and map to your CRM Leads module
You will need to have a field added to your campaign forms that captures the 'Referrer URL' you set up for your UTM tracking. Add this field and then make it hidden and then map this form field to the 'Referrer URL' field in your leads module.
That's it! Once you have this set up you can create reports in your CRM to report on any of the Lead UTM fields.
Please let a comment if this post has been helpful to your business. We would love to hear from you!
If you need any help with this please send us an email to - zoho(at)s2s(dot)services.
Helping you achieve business and personal success using Zoho Products