I thought I’d earn some karma and put some instructions up for people who are interested in integrating Google Analytics data into their Zoho CRM Web-to-Lead forms. We were doing this with Salesforce, and since switching (back) to Zoho, we’ve updated the code to work with their system. Here are the steps and a link to the code at the bottom. Big thanks to Art Wells who wrote this jQuery code, and Justin Cutroni; I directed Art to his post on integrating Google Analytics with a CRM to make this happen
First step is to create the fields that will house the Google Analytics cookie data in Zoho. Navigate to Setup > Lead Settings > Fields List and create five new fields:
- Google Analytics Source
- Google Analytics Medium
- Google Analytics Campaign
- Google Analytics Keyword
- Google Analytics Content
I set these all up as text fields, in the Description section (see below for how to create their own section), with a length of 100 just to be safe. I’m going to suppose you have a good knowledge of how these fields are used in Google Analytics. If you don’t then you can read up on campaign tracking in Google Analytics, and keep in mind that the source and medium values are used for referrals, organic search, and direct traffic also. Additionally, keyword is used for organic traffic. You’ll see an example later in this post.
With those setup, this next step is optional: I moved them all into their own section on the Lead page, called Google Analtyics data. This is all done in Setup > Lead Settings > Edit Page Layout. Pretty straightforward; setup the section and move the fields down there.
Now you need to get the values that Zoho is going to associate with these in the Web-to-Lead form. I’m assuming that you have a Web-to-Lead form setup and you are using it on your website. If not, you need to get that going; use Zoho’s support tools to figure that out. Moving along: go to your Web-to-Lead form in Setup > Lead Settings > Web-to-Lead Form and add these new fields into the form. Then get the source code.
Dump that code into a text editor, and find the 5 Google Analytics fields you created. They will have an input “name” of something like LEADCF8. You see how this value is configured: lead custom field and then a numeric value. Copy those field values and put them into Evernote or something.
Next, you’re going to take the script provided below and put it into your own .js file on your site. I can’t write code anymore, so don’t post a bunch of comments about how to use this. It’s in the jQuery on our site in swellpath.js. Dig up the file if you need to figure it out in detail. The screenshot shows you where the values from your Zoho Web-to-Lead form go.
Final step. Add this to each of the Web-to-Lead forms on your site, in the <form> tag:
This class is what triggers the script to add the hidden Google Analytics input values.
So, what do you get with all this? Check this screen shot out:
This is from a test lead, where the term “swellpath marketing analytics portland” was used to find our site. Not much to add; I think the value in this is pretty clear for sites generating leads from these Zoho forms.