We love opportunity records, because a single contact can have more than one, and because you get another 100 custom fields for each one. We like use them for a lot of things that are not the typical manually-handled sales pipeline that Infusionsoft teaches, and we’ve developed some interesting techniques for working with them.
One of our Pocket Developer customers recently asked about how to have assistants use an Infusionsoft web form to update opportunity records. For an added wrinkle, a given contact might have multiple opportunity records active at the same time.
There are two problems with this scenario. First, Infusionsoft web forms can only input data to contact records, not opportunities. Second, since there are multiple opportunities, we need to be able to designate the specific opportunity to add data to. Fortunately both of these problems can be handled with Pocket Developer, with a little finessing. It requires a teeny, tiny bit of html code and an understanding of URL query strings… which I am going to explain thoroughly below, so you’ll be up and running in no time at all.
1) Create a campaign with whatever goal trigger you want to start with.
2) Add a sequence and add two processes to the sequence:
a) Create an Opportunity — set the default options (title, stage, assigned user, etc.) to whatever you wish them to be.
b) An HTTP Post to Email Anyone. Set the “to” parameter to the email of the person you will want to fill out the form (or a field containing that information), and the templateId to the id number of the email template that will be sent to them.
3) Add a web form goal. This web form must have a field for email and a field to temporarily store the opportunity id. The opportunity id storage field can be a custom field, but since it is for temporary storage you may also choose to use a standard field that you don’t typically use. We often use the Assistant Name field for this purpose. The email and opportunity id fields can be hidden if you like, since we are going to automatically populate them with the link. You should of course also have temporary storage fields for any other information you want the user to add.
4) Copy the hosted link for the web form.
5) Go to the email template you entered in step 2a. Insert an html snippet in the body of the email. (This is where the teeny, tiny bit of code comes in.) Paste in the following:
<a href="url">Link Text</a>
This is how a link is created. <a href=”url”> says to add a link that goes to a url (we’ll add the actual url in the next step). The </a> says to stop linking. The “Link Text” in between is the text that will be made clickable by the other two parts. That’s it… all the code you need to know. (If you want to know more about html links, click here.)
6) Replace what is between the quotation marks with the hosted web form link you copied in step 4.
7) In addition to the url, we need to send a couple of pieces of data to pre-fill the form — the email address and the opportunity id. (This is where you find out about query strings. For a more thorough explanation, click here.) In order to separate this information from the url, we’re going to add question mark. Then we’re going to send in pairs of information in the format “name=value” with each pair separated by an ampersand. For example, if we needed to tell it to set the email address to “hello@theapiguys.com” and the assistant name (which we are using to store the opportunity id) to “1234”, we would add the following to the url:
?Email=hello@theapiguys.com&AssistantName=1234
Because of the way the hosted web form is coded, it will know to put the Email value into the Email field and the AssistantName value in the AssistantName field. (Note that this technique will also work if you use the Infusionsoft javascript snippet to embed your web form on your website, though in that case you will have a different url.)
But we don’t always want to send the same information. We want these values to be dynamic and send the email for the relevant contact and the opportunity id of the opportunity we just created. In order to do this, we will use merge fields. Fortunately since we’re using Email Anyone, we can even directly merge in data from opportunity records, like so:
?Email=~Contact.Email~&AssistantName=~Opportunity.Id~
When the email is generated, Infusionsoft will see this html snippet and perform the merges like it does in any other place in the email. It will transform ~Contact.Email~ into the contact’s id number and it will transform ~Opportunity.Id~ into the id number of the most recently updated (which in this case has to be the one we just created).
Note that this method does have a few drawbacks. Because you are using an html snippet for the link, it will not behave like a regular Infusionsoft link. It won’t be tracked, and there’s no way to add actions like a tag based on the link click. It also cannot complete a link click goal. So this is probably NOT a method you want to use for marketing-type emails. But for administrative purposes, this method can be very useful.
Now you’ve got your web form ready and your email template set up. When the administrator gets the email, they will click on the link and be directed to the webform, which will pre-populate with the values you’ve sent in the query string for those field, including the opportunity id. But they’re still inputting data to the contact record. It’s time to make the real magic happen… getting that info to the opportunity record.
8) Add a sequence with an HTTP Post to AnyText to copy the stored data from the contact record to the opportunity record.
Set the textToSave fields to the fields from your contact record where the data you want to copy to the opportunity is stored.
In the saveTo fields you will use reference notation to merge in the opportunity id storage field, thereby designating precisely which opportunity to write to. Reference notation looks like this:
Table(ID).FieldName
or more specifically in this case
Opportunity(~Contact.AssistantName~)._OtherInfo
The Contact.AssistantName field is where the opportunity id is stored, having been sent in by the web form which was pre-filled by the html link you created. The reference notation will go to the opportunity table, look for the entry in that table that matches what it finds in the Contact.AssistantName field, and (since this is a saveTo value) will write the matching textToSave information to the OtherInfo field for that entry.
9) (Optional) If you like to keep your data clean, you can add a short timer (a couple minutes to make sure the http post has completed copying the data) and then add another HTTP Post to AnyText to set the copied contact fields back to blank. That way, you don’t get confused by potentially old date sitting in those fields. We’ve even used this technique to prevent users from accidentally filling out the form too quickly in succession by adding a warning if the AssitstatName field is still occupied. This is especially useful when users might be handling multiple opportunities at once.
Now your system is set up so that you can update opportunity records from a web form.