Adwords and Infusionsoft — Saving Keyword Data

In this article, I’m going to show you how to find profitable keywords using Adwords and Infusionsoft. We’ll be installing a lead tracking script on your opt in page so that you will know what keywords brought your PPC leads there.

Let’s say that you’re selling Dog Training information products and you’re looking to figure out exactly which keywords bring you the highest revenue over the time. Different keywords represent different mindsets. Some people that are closer to purchase tend to use certain types of keywords, while those that are just researching will use other terms. This can help you decide what kind of message you want to present as well as decide when the right time is to “sell”.

People searching for “Dog Training” may be those that are still in the early stages of researching dog training material while those searching “how to train your dog” may have already done a few weeks of research and now they’re ready to fork over some money for some good content. In my experience, people that also use terms like “free” (e.g. “free dog training”) actually convert better strangely enough.

By going through this exercise, you’ll find some surprising insights about lifetime customer value. When you do this, look at your top 10 or top 500 customers even. I sort mine by lifetime customer value — how much money they spend over 6 months or 2 years or whatever (it’s  going to be a snapshot rather than an actual LCV since you don’t have 20 years to measure how much a customer’s really worth). So back to the dog training example, maybe you offer some dog training phone consultation at $100 per hour on top of the $47 eBook you offer. The ones that take up the consultation are more valuable to you so you can see how they found you. Eventually a pattern will emerge and you’ll find keywords to focus your energy on.

Now, if you’re only selling a straight $47 eBook, none of this is really necessary since you can easily do all of the tracking through Google Adwords Conversion Tracking. However, if you have multiple products (e.g. dog training eBook, dog training tools, physical books, DVDs, monthly membership programs, etc.), that’s when doing this kind of thing becomes a lot useful for you because the LCV will start to differ dramatically and you’ll see the 80/20 come in to play. 20% of your customers will account for 80% of your revenue.

Or, if you’re just trying to get rid of the “(not set)” keyword problem, this is a great way around that for PPC (unfortunately this won’t work for organic results on Google).

 

Setting Up Your Test Campaign

We will first need to set up a test campaign in Google Adwords. When you set up your campaign, if you’re dealing with keywords that have very high levels of traffic, it may be worthwhile to split your test campaigns by location. I have mine split by countries (USA, CA, UK, AU & NZ) because you’ll find that people’s responses can vary sometimes depending on where they’re from (at least in my experience). But you can group them all together if you like or if you’re dealing with long tail keywords.

Next, you’ll need to set up your ads.

It’s better to split your ads according to ad groups so that you serve more relevant ads. But if you’re lazy like me, you can just have 2 ads running for the whole campaign and see which one performs better.

When you set the URL for the campaign, you should use something like this:

YourWebsite.com/LandingPage?utm_source=AdWords&utm_medium=PPC&utm_term={keyword}&utm_content={creative}&utm_campaign=[write your campaign name here]&Network={ifContent:Content}{ifSearch:Search}&SiteTarget={placement}

This tells our server what keywords the user typed in (denoted by {keyword}), and which ad group and campaign they came from. I’ll show you how you can then capture that information on Infusionsoft and store it in the contact’s record in the next step. Now does this mean that you don’t have to have Adwords Conversion Tracking? Of course not! You should still have conversion tracking enabled so that you can more easily see what’s doing well and have the option to use conversion optimizer.

Setting Up Your Infusionsoft Campaign

In order to store keyword and other relevant Adwords data on Infusionsoft, you’ll need to create some custom fields.

You can do so by going to the Admin tab -> Settings.

And then click on “Go” next to Contact:

Custom Field in Infusionsoft

 

We simple add “Field” and we can just use normal text fields for our purpose.

Add Custom Field for Infusionsoft

Then create the fields with these names: Term, Source, Medium, Content and Campaign:

 

Custom Field for Contact Records

 

If you do offline conversions (for example, you do consulting and you take credit cards over the phone or a sales rep closes the deal and they don’t visit any kind of “thank you” page where you can tell Adwords that a conversion event has occurred), then you may need to “close the loop” manually. In this case, you can also create an extra field called gclid and upload the conversion manually to Adwords (together with time and value of conversion).

Now we proceed to create the opt in form.

Choose your Opt In method (you can choose “Sign up for newsletter” or “Request Information”):
Infusionsoft Goals

Now create 5 “hidden” fields so that they don’t show up on the form:

Create a Hidden Field in Campaign Builder

After you have created your 5 hidden fields, you’ll need to choose the custom fields we created earlier. Once you do this, you should have something like this:

Hidden Fields and Normal Fields

Setting Up Your Web Page

This is where we’re going to have to get our hands a bit dirty and you may need a developer to do this for you.

Firstly, copy the code below to the header of your page.

<script type="text/javascript">// <![CDATA[
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); 
   document.write("<script src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'>" + "</sc" + "ript>");
// ]]></script><script type="text/javascript">// <![CDATA[
var pageTracker = _gat._getTracker("UA-)"); pageTracker._trackPageview(); // // This is a function that I "borrowed" from the urchin.js file. // It parses a string and returns a value.  I used it to get // data from the __utmz cookie // function _uGC(l,n,s) {  if (!l || l=="" || !n || n=="" || !s || s=="") return "-";  var i,i2,i3,c="-";  i=l.indexOf(n);  i3=n.indexOf("=")+1;  if (i > -1) {
  i2=l.indexOf(s,i); if (i2 < 0) { i2=l.length; }   c=l.substring((i+i3),i2);  }  return c; } //  // Get the __utmz cookie value. This is the cookies that  // stores all campaign information.  //  var z = _uGC(document.cookie, '__utmz=', ';');  //  // The cookie has a number of name-value pairs.  // Each identifies an aspect of the campaign.  //  // utmcsr  = campaign source  // utmcmd  = campaign medium  // utmctr  = campaign term (keyword)  // utmcct  = campaign content   // utmccn  = campaign name  // utmgclid = unique identifier used when AdWords auto tagging is enabled  //  // This is very basic code. It separates the campaign-tracking cookie  // and populates a variable with each piece of campaign info.  //  var source  = _uGC(z, 'utmcsr=', '|');  var medium  = _uGC(z, 'utmcmd=', '|');  var term    = _uGC(z, 'utmctr=', '|');  var content = _uGC(z, 'utmcct=', '|');  var campaign = _uGC(z, 'utmccn=', '|');  var gclid   = _uGC(z, 'utmgclid=', '|');  //  // The gclid is ONLY present when auto tagging has been enabled.  // All other variables, except the term variable, will be '(not set)'.  // Because the gclid is only present for Google AdWords we can  // populate some other variables that would normally  // be left blank.  //  if (gclid !="-") {        source = 'google';        medium = 'cpc';  }  // Data from the custom segmentation cookie can also be passed  // back to your server via a hidden form field  var csegment = _uGC(document.cookie, '__utmv=', ';');  if (csegment != '-') {        var csegmentex = /[1-9]*?\.(.*)/;       csegment    = csegment.match(csegmentex);        csegment    = csegment[1];  } else {        csegment = '(not set)';  }  // // One more bonus piece of information.   // We're going to extract the number of visits that the visitor // has generated.  It's also stored in a cookie, the __utma cookis //  var a = _uGC(document.cookie, '__utma=', ';'); var aParts = a.split("."); var nVisits = aParts[5]; function populateHiddenFields(f) {        f.source.value  = source;        f.medium.value  = medium;        f.term.value    = term;        f.content.value = content;        f.campaign.value = campaign;        f.segment.value = csegment;        f.numVisits.value = nVisits;       alert('source='+f.source.value);        alert('medium='+f.medium.value);        alert('term='+f.term.value);        alert('content='+f.content.value);        alert('campaign='+f.campaign.value);        alert('custom segment='+f.segment.value);        alert('number of visits='+f.numVisits.value);       return false;  }
// ]]></script>

Afterwards, get your opt in code from Infusionsoft. Make sure you choose HTML Code Unstyled.

Playground

Copy and paste this to your favourite code editor and look for something that looks like this (towards the bottom):

    <input type="hidden" name="inf_custom_Term" value="null" />
    <input type="hidden" name="inf_custom_Content" value="null" />
    <input type="hidden" name="inf_custom_Source" value="null" />
    <input type="hidden" name="inf_custom_Medium" value="null" />
    <input type="hidden" name="inf_custom_Campaign" value="null" />

All you need to do is replace that with this:

<script type="text/javascript">// <![CDATA[
document.write('<input id="term" name="inf_custom_Term" type="hidden" value="'+term+'"/>')
document.write('<input id="content" name="inf_custom_Content"  type="hidden" value="'+content+'"/>')
document.write('<input id="campaign" name="inf_custom_Campaign"  type="hidden" value="'+campaign+'"/>')
document.write('<input id="source" name="inf_custom_Source"  type="hidden" value="'+source+'"/>')
document.write('<input id="medium" name="inf_custom_Medium"  type="hidden" value="'+medium+'"/>')
// ]]></script>

And the Voila! Now you will have detailed keyword data for all of your PPC leads.

Note that you can use this method with Unbounce but not with Leadpages. If you would like me to help you implement this, fill out your details here.
If done correctly, you should see something like this in your contact’s information inside of Infusionsoft.

custom lead tracking infusionsoft

UPDATE JAN. 2015: Some have emailed me asking whether this method will work with Universal Analytics (UA). The answer is no. The data is no longer stored on the client side. For those of you technically minded, you can try an alternative: https://github.com/dm-guy/utm-alternative

13 Comments
  • Nefer Lopez
    March 10, 2014

    Does the procedure you described work for Universal Analytics?

    Thanks for the great post, Rui!

  • Darrell
    April 30, 2014

    Rui – thanks a ton for this. We followed the process and your instructions nailed it.

  • Adam
    September 17, 2014

    So there is no other way to get the adwords data associated with your converted contacts into IS? If you have an adwords campaign with 100,000+ keywords you are saying each ad has to use manual tagging?

    We are using unbounce and we have successfully created all the utm parameters. So in order to get those parameters from Adwords > Unbounce > Infusionsoft I need to manually tag each ad?

    • Rui Zhi
      September 17, 2014

      If you already have the correct utm parameters, all you need to do is pass that info onto Infusionsoft

      If not then you can update your adwords ad so that it’s passing that info on. You can do it by using the URL format that I gave which automatically appends the utm parameters onto the URL

  • TR
    October 21, 2014

    Did you mean to comment out the majority of the code in the analytics js snippet for the header? It’s not functioning as is, especially since you have uncommented closing braces without anything opening them.

  • Kevin
    November 20, 2014

    Thanks for the great article! Can you setup rules in Infusionsoft based on those hidden values added to the contacts record?

    For instance, if contact submits form and term contains indian then add contact to broadcast sequence Indian Food Autoresponder?

    Thanks for any help!

    • Rui Zhi
      November 20, 2014

      Hey Kevin,

      Yes, you can definitely do it! You just create a filter for the list (term = ‘indian’ for example). You can also segment people in campaigns using the decision diamond based on this.

      Cheers!

      • Kevin
        November 20, 2014

        Thanks so much Rui for your quick response. So funny, because I have talked to two infusionsoft salesman and both told me this kind of functionality was not possible. I couldn’t believe it so I started searching Google for “hidden input fields infusionsoft” and came across your blog post here. I would love to use a platform like Infusionsoft, but we desperately need to be able to use automation rules based on dynamically generated hidden input fields in forms. Thanks again!

        • Rui Zhi
          November 20, 2014

          You’re welcome!

  • Jeff T
    November 26, 2014

    How do I pass the “search term” from Adwords when using broad +match via UTM ?

    • Rui Zhi
      November 26, 2014

      It doesn’t matter if it’s broad match or exact match. It gives whatever terms the user searched

  • Jean
    February 23, 2015

    OMG this is amazing. Code works perfectly after removing the comments. Thanks a million times.

  • Andrew
    June 18, 2015

    Just wondering if I could get the instructions for setting this up via UnBounce like you mentioned.
    Sent an inquiry through but haven’t heard back yet.

    Thanks!

Leave a Reply

Your email address will not be published. Required fields are marked *