How to Connect Salesforce to Google AdWords

Google AdWords campaigns are a powerful tool for keeping your pipeline filled with leads and opportunities. However, you can’t improve on your paid-advertising efforts if you don’t know where the […]

About the Author: Gary Galvin

March 1, 2017

Salesforce and Google Adwords

Google AdWords campaigns are a powerful tool for keeping your pipeline filled with leads and opportunities. However, you can’t improve on your paid-advertising efforts if you don’t know where the prospects come from. Connecting your Salesforce to Google AdWords delivers clear attribution, so you know what keywords and campaigns your opportunities are coming from. Use this guide to learn the process of integrating your AdWords conversions into Salesforce leads and opportunities.

Before We Begin

  • Log into Salesforce with a system administrator account.  In order to make proceed with these changes to Salesforce, you need edit privileges for the following fields: Organization, LeadStatus, OpportunityStage, LeadHistory, Lead, OpportunityFieldHistory and Opportunity. You also need to be able to make custom fields with this account.
  • Make sure you have auto-tagging enabled in your AdWords account.
    • Log into your Google AdWords account.
    • Click the “Gear” menu in the upper-right corner of the screen.
    • Choose “Account Settings” and click the “Tracking menu” option.
    • Click the “Edit” option in the Auto-tagging section.
    • Select “Destination URL Auto-tagging” and
    • click “Save Changes.”
  • Have permissions to edit your website code.
  • Your Salesforce account must allow you to create custom fields and enable field history tracking.
  • Have access to Salesforce’s web-to-lead feature, to send lead information from your website into Salesforce Leads object.

Now you’re ready to get started.

Step 1: Salesforce Configuration

Opportunity Object Configuration

  1. Go to the Opportunity object in your Salesforce account.
  2. Make a new custom field named “GCLID” (this stands for Google click ID).
  3. Create a descriptive label for the field, and expand the length to 255 characters.
  4. Make sure that “Set History Tracking” is enabled for the “Stage” field.  (Instructions can be found here)

GCLID Custom Salesforce Field

Lead Object Configuration

  1. Go to your Lead object.
  2. Use the same steps above to make another custom field with identical parameters.
  3. Click “Map Lead Fields,” and map the Lead.GCLID to the Opportunity.GCLID field (instruction here)
  4. Click “Save.”

 

Step 2: Setting Up Your Website

This step will allow your website to save the Google Click ID (“GCLID”) as a cookie and then carry that value to your new GCLID Salesforce field.

Use the following Google-provided JavaScript in the head section on any web pages that have Salesforce lead forms on them.

<script type=”text/javascript”>
function setCookie(name, value, days){
    var date = new Date();
    date.setTime(date.getTime() + (days*24*60*60*1000)); 
    var expires = “; expires=” + date.toGMTString();
    document.cookie = name + “=” + value + expires;
}
function getParam(p){
    var match = RegExp(‘[?&]’ + p + ‘=([^&]*)’).exec(window.location.search);
    return match && decodeURIComponent(match[1].replace(/\+/g, ‘ ‘));
}
var gclid = getParam(‘gclid’);
if(gclid){
    var gclsrc = getParam(‘gclsrc’);
    if(!gclsrc || gclsrc.indexOf(‘aw’) !== -1){
        setCookie(‘gclid’, gclid, 90);
    }
}
</script>

It is recommanded to add this JavaScript code to every webpage.  Most content management system (CMS) packages such as WordPress allow you to add this JavaScript into the template once and then the CMS will add it to every webpage.

Create your Salesforce Web-to-Lead Form

  1. Go back to Salesforce and go to the web-to-lead section in Salesforce and follow the standard process to set up your forms.
  2. Make sure to include the GCLID lead field in this form.
  3. Search for the HTML code GCLID: and delete the maxlength and size tags.
  4. Edit the field type so it is “hidden” rather than “text.”  This will make sure that the field does not show up on the form and is rather hidden from the website user.

    <input id=”xxxx” name=”xxxx” type=”hidden” />

  5. Copy and paste this code in between the FORM HTML (<form)>…</form>) tags on your web forms.
  6. Every webpage that has a Salesforce web-to-lead form must also include this JavaScript between the <head> tags.
    <script>

  window.onload = function getGclid() {
document.getElementById(“xxxx”).value = (name = new     RegExp(‘(?:^|;\\s*)gclid=([^;]*)’).exec(document.cookie)) ?
name.split(“,”)[1] : “”; }
// window.onload() may not be supported by all browsers.
// If you experience problems submitting the GCLID as a
// hidden field, consider using an alternate method to
// call this function on page load.
</script>

*Note: The HTML generated by Salesforce will include the ID and you will replace “xxxx” with that id.

 

Step 3: Configuring Your Google AdWords Account

  1. Log into your Google AdWords account and click the “Settings” menu in the upper-right corner of the screen.
  2. Choose the option “Linked Accounts.”
  3. Go to the Salesforce section and select “View Details.”
  4. Click the button to add an account, and press the “Continue” button.
  5. Enter the Salesforce account information, and choose “Set Up Conversions.”

Setting Up Conversions

  1. Select any boxes in the Milestones section relating to relevant lead and opportunity options that should be tracked as conversions.
  2. Go to the Conversion column and choose these leads and opportunities from the menu.
  3. Choose “Create a conversion” and name it.
  4. Click “Done.”
  5. Next you will go to “Value”, “Count” and “Conversion Windows” to configure these fields for your sales funnel.
  6. Choose “Create” and pick the best import schedule for your team.
  7. Save your changes.

Now your AdWords conversion data automatically imports into your Salesforce.

 

Sources:

https://support.google.com/adwords/answer/6299296
https://help.salesforce.com/articleView?id=setting_up_web-to-lead.htm&type=0https://help.salesforce.com/articleView?id=tracking_field_history_for_standard_objects.htm&type=0
https://support.google.com/adwords/answer/3095550
http://searchengineland.com/adwords-conversion-import-salesforce-launch-251234

GA Connector is the integration we’ve been waiting for

We’ve gone through the not-so-easy manual process of connecting Salesforce and Google AdWords data, so we were thrilled to discover GA Connector — this tool allows you to easily and seamlessly sync your sales and marketing data so you can focus on running successful campaigns. If you’re interested in integrating your sales and marketing data, check out our five reasons why should connect your Salesforce and Google AdWords data with GA Connector.


Also published on Medium.

Share article

Related Articles —

— Also on Galvin Tech —


Also published on Medium.