How To Set Up and Track Keyword Origination from Multiple Sources in Salesforce

The holy grail for most marketers I talk to is being able to track a lead – or even a sale – all the way back to the original source keyword. If the marketer knew that, he or she could easily begin to understand what to focus on in terms of keyword targets for organic or paid search.

Are you running a bloated PPC campaign with dozens of ad groups, and hundreds or even thousands of keywords, not knowing which keyword drove the conversion, lead, or months later, the sale?

Are you using and paying for Salesforce, but have not taken the time to properly pipe in your AdWords or Google Analytics data?

Sounds like a no-brainer, but trust me – there are lots of companies out there with revenues in the tens of millions, or hundreds of millions, who are not doing this right.

Their PPC budgets are way into the six figures per month, and the license fees for Salesforce could probably pay for two or three employees in my company.

However, the issue is not piping in AdWords or Analytics – there are tools in the App Exchange which will do this for you – it’s the other sources that are very difficult, such as live chat, external landing pages, or phone calls. What keywords drove those actions?

Sure, the Salesforce web-to-lead forms help make the job easier, but for some websites, chat and phone make up a considerable amount of leads.

Are you relying on your sales team to manually enter the data?

They may know the lead came from “Google” or a “search engine”, but rarely will they know what specific keyword the user typed in, or how to make strategic decisions based on only a generalization of where the lead originated.

Such issues were quite prevalent at Vancouver, B.C.-based PEER 1 Hosting, one of the top 5 managed hosting and colocation companies in the world with revenues upwards of $100MM per year.

One of the feedback loops we wanted as part of the SEO campaign strategy was to understand which searches drove traffic, then leads, then sales. If we could understand the keyword which drove real customers, then we would take those keywords and SEO the hell out of them. Who cares about the rest – they don’t drive sales anyway. Of course, this is much easier said than done.

So the guys at PEER 1 Hosting figured out how to pipe the tracking data into Salesforce to not only track the keyword, but the original source, as well as other information too.

In this post, you’ll learn how to set everything up and track SEO, PPC, live chat and phone calls.

Step 1: Set up your Salesforce lead form fields

All your necessary contact information fields should already be in place, but add a dropdown field for the type of source (Web, Phone, Chat). To help organize information captured from the visitor’s session, create a section for the marketing metrics that will need to be captured. Typical fields for this would be keyword, landing page, referrer URL, SEO or PPC, campaign, ad group, and match type.

Step 2: Determine the URL parameter strings to use for each campaign

In the case of PPC campaigns, most systems allow for a custom URL structure, and this can be tailored to suit your data capture system as well as maintain compatibility with Google Analytics.

In the case of this PPC string, the parameter names are compatible with Google Analytics and PPC ad campaign information is also captured in Google Analytics without any additional effort when it reaches your site. &utm_campaign=July2011promo&source=Google

Step 3: Create a mechanism to capture incoming URL or referrer information and store it so that it stays with the visitor

This can be done with a session or with cookies. Cookies were chosen as the preferred method because the information can be stored with the visitor for a pre-determined length of time, and are still available on subsequent visits.

Store each captured field in a unique cookie variable, and assign the length of time for which it should be remembered. In the case of capturing organic search information, parse the external referrer URL so that it extracts the domain name and typical search parameters, (‘q’ for Google, ‘query’ for AOL, ‘p’ for Yahoo, etc) into cookie variables.

This capture code resides at the top of all site pages globally and is also included on stand-alone landing pages.

Step 4: Submitting information to Salesforce via web form

The web contact form is the simplest of the three capturing mechanisms for gathering user information and submitting to Salesforce since all the interaction between their browser, your website and Salesforce is done by the visitor’s action. Salesforce has two methods available for data transmission, ‘web-to-lead’ for simple form posts and an API for more complex and secure transmission.

On form submission, retrieve the information that has been stored in the cookies in step 3 and send that to Salesforce with the form post, as hidden fields using web-to-lead, or as part of the lead object using the API method, mapped to the Salesforce fields that were created in Step 1.

A visitor searching for “peer 1 hosting” in Google and clicking on a paid link, results in something similar to the following in Salesforce.

Step 5: Add an online chat system to the mix

PEER 1 Hosting uses LivePerson as its live chat platform. This not only allows visitors to ask questions about products and services in real-time, but also serves as a channel for capturing sales leads. In the past, visitor information had to be entered manually into Salesforce if the chat representative wanted to create a lead record.

A LivePerson / Salesforce Integration package exists in the AppExchange, but it didn’t go the full distance in terms of capturing custom metrics from visitors which become new leads. Using LivePerson’s monitor tag, data from the visitor’s cookie is each published as a custom variable and is picked up by LivePerson when a chat session is started.

In this example, LivePerson now has access to search engine, keyword, incoming referrer and landing page for the length of time that you specified in the visitor’s cookie.

lpMTagConfig.sessionVar[lpMTagConfig.sessionVar.length] = '';
lpMTagConfig.sessionVar[lpMTagConfig.sessionVar.length] = 'p1_fc_sekw=peer 1';
lpMTagConfig.sessionVar[lpMTagConfig.sessionVar.length] = 'p1_fc_serefurl=';
lpMTagConfig.sessionVar[lpMTagConfig.sessionVar.length] = '';

Several other visitor variables can be captured using this method.

Step 6: How do you get this chat information into Salesforce?

In LivePerson, an operator alert was created and is triggered every time an active chat is initiated. This alert opens up a LivePerson console window with a link to a web form on’s servers. Since the captured information in the previous step is now available to the LivePerson application, it is sent via this link’s URL string with all the necessary custom variables plus some of LivePerson’s built-in variables back to so that it can be processed via the web form API method.

The advantage here is that the chat operator now simply fills in the lead’s basic contact information and the rest of the captured data is transmitted along with it to Salesforce. This visitor’s information is therefore captured without them needing to fill in a form and allows for the capture of all, and more of, the information that would have been available if they submitted a lead form themselves.

Step 7: What happens if a visitor phones us?

The biggest challenge was to discover a way to track phone leads back to a source without asking each visitor. In the past, a lead would be entered directly into Salesforce by the phone representative, and the lead record flagged as a ‘phone lead’. This was the only additional information captured.

Mongoose Metrics provided a solution that helped add call tracking to our system. By setting up a Mongoose campaign and adding a small piece of JavaScript to our pages, the phone number on our website can be made to change on-the-fly and present a unique phone number to each visitor that has keyword or specific campaign information attached to their visit. This number is reserved temporarily for this user and Mongoose Metrics’ system stores analytics information that pertains specifically to this phone number.

Now, when the visitor calls this unique number and the phone representative enters the visitor’s incoming caller ID into the Salesforce lead form, the Mongoose Metrics / Salesforce integration updates the lead record with several additional fields including keyword, campaign, call duration, and URL information.

Put all these pieces together and the main methods of visitor contact is trackable back to originating source and keyword through web form, chat and phone call. No system is perfect and there are several reasons why data would perhaps not be captured, but if information is available it should not be discarded.

Step 8: Additional considerations

PEER 1 Hosting was comfortable enough with the data transmission process to further identify when a visitor arrived through any combination of PPC and organic sources on subsequent visits and to then determine if first-click or last-click took precedent in the case of multiple entries. In the case of both PPC and organic information being available, both are captured. To do this, set multiple cookies to store first-click and last-click information, and create fields in Salesforce identifying PPC and organic sources.

Since PEER 1 Hosting uses more than one PPC vendor across multiple sites, an additional vendor identifier ‘v=vendor’ was added to PPC URLs, and PEER 1 Hosting added themselves as a unique vendor to their own campaigns, whether it be website, newsletter, or social media efforts.


PEER 1 Hosting is now able to look at several combinations of reports, such as:

  • Which keywords drove the most chat leads
  • Which marketing campaign was most successful for all sources of contact
  • Which PPC vendors drove the most sale value
  • How many Twitter campaigns generated leads last month
  • And much more…

— Ryan Kelly

default author image
About Ryan Kelly
Ryan Kelly is founder and CEO of Pear Analytics, and Internet marketing software and services company based in San Antonio, Texas. A mechanical engineer, Ryan has extensive experience in web analytics and search engine optimization. Pear's free website analyzer software has run nearly 1 million websites since it's launch in 2009, and continues to run at nearly one report per minute.
» More blog posts by Ryan Kelly