Add Google Analytics Data to Zoho CRM Lead Forms

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.

iHere is the JavaScript we are using. Enjoy using this!

Adam Ware

Adam Ware - President & CEO

Developer turned full-stack marketer turned CEO. Adam has been working with web analytics platforms for over 15 years, and has been helping promote websites for almost 2 decades. Outside of the office: Chicagoan raising Minnesotans, Willamette U. grad, pug lover, hockey player, and occasional surfer.

12 Responses to “Add Google Analytics Data to Zoho CRM Lead Forms”

  1. Kevin Jemison

    Thanks for posting this. I've been researching web analytics + CRM integration solutions that are a bit more affordable than Omniture SiteCatalyst + for some small business clients, particularly ones that already have Google Analytics implemented. Definitely something to explore further. Have you tried to pass any other data out of GA to Zoho, like number of pageviews/visits or anything else?

  2. wheresitworking

    Sorry for the delayed response Kevin. Glad you enjoyed the post. Yes, you can pass any fields in that are available in the GA cookies (visit number, visit duration, custom variables, etc.), so you would just need to pull the pageview value out of the utmb cookie.

  3. Mashhood Rastgar

    excellent post.. just a minor point: paragraph 6 – They will have an input “value” of something like LEADCF8 : got me there for a second, should be cleared that its the name attribute, not the value attribute the post is talking about.

    • Adam Ware

      You’re right Mashhood. Thanks for pointing that out. Correcting it now.

  4. RAD MKT

    Great post… I’ve been wanting to get this setup up for ages.

    Unfortunately, I’m having issues getting it to work. I went through all of the steps that you outlined above, but am not getting any data to submit for the GA fields (source, medium, etc).

    A couple of questions:

    In the Zoho Web-to-Lead Form: Are the GA fields supposed to be hidden, or not included at all?
    jQuery: Does the ‘cookie.js’ file need to be uploaded as well?
    General: How can I check that I’m correctly pulling the cook info?

    Any insights are most welcome and thanks for an awesome post.


  5. Mark

    Thanks! I implemented this but I can’t tell if it’s working. I added before the script and after. To many this was probably obvious, but I’ve never done this kind of thing before.

  6. Mark

    It looks like my code got deleted from my post. Using the “Greater than” and “Less than” characters to replace the “-” characters I inserted:
    -script type=”text/javascript”-
    before the js code and:
    after the js code

  7. Mark

    Again, thanks for posting!
    Like RAD MKT I can’t get this to work.
    I’m using Intuit Sitebuilder. Other js code (like Google scripts for tracking) seems to work. But this does not work (i.e. fill in the fields in Zoho). I put class=’trackmaster’ in my form tag and I modified then copied the js code into the header of my page. Anyone have any troubleshooting suggestions?

    • Adam Ware

      Sorry everyone, we aren’t using Zoho any more so we haven’t used this code in more than a year. As for the problems you’re having, I’d recommend getting a skilled JavaScript developer to take a quick look at it. They’ll be able to troubleshoot and work around the nuances of your CMS etc.

  8. Tim Shorey

    Does this still work with Universal Analytics? I seem to be just getting (direct), (none), (not set) etc even when I have come in to the site from an AdWords link…

  9. Phil

    Thanks for the good read Adam,

    I have a client that uses Zoho, but is also now using Universal Analytics. I really like the power of Universal Analytics, but I’m starting to see some limitations when it comes to adding tracking data (UTMZ) to a contact or signup form which is then stored in a 3rd party CRM. This data is needed to attribute a sale from campaign during a longer sales cycle. As Universal Analytics no longer has data that can be parsed right from the UTMZ cookie, have you seen a work around for this for Universal Analytics which allows for metrics such as Source, Medium, Campaign data to be pulled?



Leave a Reply

Loading Facebook Comments ...

Get Our Newsletter

To keep up with the latest news from SwellPath on digital advertising, analytics, and SEO, sign up for our newsletter.