Get the timezone of your leads.

Business scenario:

It’s a no brainer that prompt call backs and engagement right through the purchase cycle have a direct bearing on your lead conversion. To do this, it is very important that you call/email your clients in their time zone. Wouldn’t it be great if your CRM automatically sorts your leads based on their time zone? The Function (custom function) I share today helps you do just that.

Add this function to the Leads module and fetch the time zone of the leads based on their address. We will make use of Google APIs to meet this requirement. Create a custom field in Leads module to capture the time zone details. Furthermore, you get the list view of the Leads module to display the time zone along with the name, contact number and the other fields. Segregate your clients based on their time zone and target your nurture programs accordingly. This ensures your sales calls and emails are addressed at the right time and help you win more deals.

Getting started with the function:

  1. Go to Setup > Automations > Actions > Functions > Configure Function > Write your own.
  2. Provide a name for the function. For example: "Lead Time Zone".
  3. Select the moduleto be associated as Tasks. Add a description(optional).
  4. Copy the code given below.
  5. Click "Edit arguments".
  6. Enter the name as "leadId" and select the value as "Lead Id".
  7. Enter the name as "zip" and select the value as "Zip Code".
  8. Click Save & Execute Script.
  9. Save the changes.

The code:

For v2 Editor - DRE:

data = getUrl("https://maps.googleapis.com/maps/api/geocode/json?address=" + zip + "&key=xxxxxxxx");
result = data.getJSON("results");
geometry = result.toJSONList().get(0).getJSON("geometry").toJSONList();
location = geometry.get(0).getJSON("location");
lat = location.getJSON("lat");
long = location.getJSON("lng");
timezone = getUrl("https://maps.googleapis.com/maps/api/timezone/json?location=" + lat + "," + long + "&timestamp=0900000000&key=yyyyyyyy").getJSON("timeZoneName");
update = zoho.crm.update("Leads", leadid.toLong(), {"Time_Zone": timezone});
info update;

Note:

  • The above code works only for API V2.0 and not the previous version.
  • Once the function is added, you can set the function in a Workflow rule to trigger it upon the creation of a lead.
  • Replace the "xxxxxxxx" in the code by getting the key from the following link.
    https://developers.google.com/maps/documentation/geocoding/intro
  • Replace the "yyyyyyyy" in the code by getting the key from the following link.
    https://developers.google.com/maps/documentation/timezone/start
  • In both pages, click Get A Key from the top-right of the page and give a Project name to get the keys.

Found this useful? Try it out and let us know how it works! If you have questions, do not hesitate to ask! Share this with your team if you find it useful!

Return to Tips