Using FormAssembly to Automatically Attach a Campaign to your Leads in Salesforce:

Many thanks to Jimmy, whose company Plum Heating and Cooling provides Evaporative Cooling in Melbourne, Australia.

The following post explains how to use Daddy Analytics and FormAssembly to autopopulate the Campaign of your Leads. To do this, you must of course have FormAssembly as your Web-to-Lead form, and Daddy Analytics.

Warning – this is a technical article, and is intended for Salesforce administrators.

What you will need:

  1. Campaign ID’s of all the campaigns you would like to add from Salesforce
  2. Details of all the links built using the Google URL Builder Tool you would like to track
  3. Formassembly Account

First of all, you will need all of the Campaign ID’s of the campaigns you would like to track. In my case, I have 4x Campaigns I would like to track using DaddyAnalytics / Formassembly

Campaign ID: 70190000000BGFk – Start Local Business Directory
Campaign ID: 70190000000B6yR – Yellow Pages Online Directory
Campaign ID: 70190000000BB2J – Google Adwords 2013 Campaign
Campaign ID: 70190000000BGVn – Google Organic

Next, you will need to add the GA REFERER fields into your Formassembly Form. This can be found when you are editing your forms under ‘Add Content -> More -> Analytics -> GA Referrer’

Save your Form in Formassembly and Leave the Form Builder.

Under the ‘Publish’ menu, Locate and Click on ‘Show how to pre fill form data dynamically’

Locate the following fields and note the TFA_XX Number on each, In my case they are:

Source (from Google Analytics) tfa_87
Campaign (from Google Analytics) tfa_88
Medium (from Google Analytics) tfa_89
Keywords (from Google Analytics) tfa_90
Content (from Google Analytics) tfa_91

Using the Google URL Builder tool (or existing URLS you have built using the tool previously) You should get the values for each of the campaigns you would like to track.

Source – startlocal
Campaign – StartLocal2013-2014
Medium – classifieds
Content – textad

Repeat this for every Campaign / Link you would like to track.

Campaign 1:
Source – startlocal
Campaign – StartLocal2013-2014
Medium – classifieds
Content – textad

Campaign 2:
Source – yellowpages
Campaign – YellowPages2013-2014
Medium – classifieds
Content – textad

Campaign 3:
Source – google
Campaign – GoogleAdwords2013
Medium – cpc
Content – textad

Campaign 4:
Source – google
Campaign – (organic)
Medium – organic
Content –

Now we can work on building the formula to place into Formassembly.

You need to access your Salesforce Connector in Formassembly by going to Connectors -> Salesforce V2.0

You need to create a new ‘CampaignMember’ object:

‘Always Create a New Record’

Skip IF = Needs to be checked –

This ‘create’ operation is skipped if the following formula returns TRUE:


This formula tells Formassembly to skip processing the campaign if the TFA_87 (Source) field is not equal to ‘StartLocal, YellowPages, or Google’. You can add or remove arguments depending on your campaigns.

The first field you should map is the Campaign ID (required)

Use the following Template to get you started using the values we have recorded above:

@IF(@AND(%%tfa_87%%=”SOURCE”,%%tfa_89%%=”MEDIUM”,%%tfa_91%%=”CONTENT”,%%tfa_88%%=”NAME”),”SF CAMPAIGN ID”,””)


NB: It is easier to build this formula using Notepad or Wordpad as you can work on separate lines and the paste the value back into Formassembly.

My formula looks like the following:


Note that when adding extra lines, you need to remove the “” section from the last line and place it at the end of the formula, and add 1x bracket for every line to close the formula.

The Second Field you should add is the ‘Status’ field.

Status = Responded (Or whatever the default response is for your SF Campaigns)

Save the Connector and you are done!

Test this by either following one of your Google URL Builder tool links (Dont Forget to clear your cookies first) and filling out the form. Go to the new lead in Salesforce and it should be attached to a campaign!

Leave a Reply