Pilotpress Shortcodes and Merge Fields

Recently, Ontraport re-did their online support pages and some of the information that used to be available is temporarily unavailable. Something that was missing at the time of this post was information about Pilotpress shortcodes and merge fields. Here is a list of merge fields and shortcodes you can use at your WordPress website if you have an Ontraport account and the Pilotpress plugin installed.

Merge Fields

These are shortcodes you can use to show information about the logged-in contact from their Ontraport contact record. The format is [pilotpress_field name='{field name in Ontraport}’].

Examples:
[pilotpress_field name=’First Name’]
[pilotpress_field name=’Last Name’]
[pilotpress_field name=’Email’]
etc.

Functional Shortcodes

Pilotpress includes some useful shortcodes you can use to display content to your Ontraport contacts based on membership levels and tags they may or may not have.
(note: the braces {} below are placeholders; don’t include them in your shortcodes.)

  • [show_if has_one='{membership level names separated by commas}’]content[/show_if]
  • [show_if has_all='{membership level names separated by commas}’]content[/show_if]
  • [show_if not_one='{membership level name}’]content[/show_if]
  • [show_if not_any='{membership level names separated by commas}’]content[/show_if]
  • [show_if has_tag='{tag name}’]content[/show_if]
  • [show_if does_not_have_tag='{tag name}’]content[/show_if]
  • [show_if is_contact]content[/show_if]
  • [show_if not_contact]content[/show_if]
  • [show_if is_cookied_contact]content[/show_if]
  • [show_if not_cookied_contact]content[/show_if]
  • [pilotpress_sync_contact]

Login Form

  • Default: [login_page]
  • With user selected customization: [login_page style=’default’ forgotpw=’on’ width=’320px’ bgcolor=’#ffffff’ textcolor=’#333333′]

Removing or Editing Ontraport Transaction “Offers”

According to the documentation on this page, if you create an “offer” to be used to add transactions in Ontraport, “there is no way to edit or remove it later”. However, there is a way to remove offers using the live Ontraport API page.

1) Find the “Offers” endpoint on the Live API page.
2) Open the GET/Offers (“This will get a list of Offers”) section and click the “Try it out!” button.
3) In the list of offers it shows, find the “id” of the offer you want to get rid of.
4) Open the PUT/Offers (“This will update an Offer’s data”) section and put that id into the “id” field and select 0 for the “public” field; then click the “Try it out!” button.

This offer will no longer appear in the list of offers when you add transactions in a contact’s record in the Ontraport app.

Uploading a Tax Table to Ontraport

Our bookkeeper told me it would be great if we could collect the correct sales tax % from our New York customers based on their county of residence. Up to this point, we’d just been collecting one tax rate for all New York residents.

Well, there turn out to be 62 counties and I didn’t want to have to manually enter these 62 sales tax rates into the Ontraport app. So, I decided to set up a way to import a tax rate by county CSV file that populated our Ontraport account with the county tax rates.

I put this “tool” here at this website. Any Ontraport customer can use it; you just need an API key and App ID for your Ontraport account.

Once you have an API Key + App ID, go over to the tax table import tool and give it a try.


Adding a Custom Dropdown Field to a Contact Record in Ontraport using the API

Ontraport allows you to add custom fields to contact records. There are various field types:

  • Checkbox – Checkbox for yes and no values.
  • Country – Dropdown list for Countries
  • Date – Calendar box to select date.
  • List Selection – List of multiple values; allows selection of one or more.
  • Long Text – Text field for long descriptions.
  • Numeric – Field for whole numbers only.
  • Price – Field for entering a price.
  • Phone – Field for phone numbers.
  • State – Contains a list of states and regions.
  • Dropdown – Dropdown list of multiple values allowing the selection of one of the values.
  • Color – Dropdown list of multiple values allowing the selection of one of the values and color
  • Text – Field for alpha-numeric values such as proper names, serial numbers, etc.
  • Email – Field for email address.
  • SMS – Field for a phone number that can receive SMS messages.
  • Address – Field for a street address.

When you’re adding a Dropdown or List Selection field, you sometimes have lots of options to add, and adding them manually within the Ontraport app can be a bit arduous. It would be nice to be able to import them.

Well, if you can get your options into a comma-delimited list, you can do just that within Ontraport’s live API interface.

Let’s say you want to add a custom field to your contact records in the Contact Information section called “NY County” with a selection of 62 options (there are 62 counties in New York state).

Well, you can use the “POST /objects/fieldeditor (https://api.ontraport.com/1/objects/fieldeditor)” API endpoint and send it a JSON string that looks like this:

{  
   "objectID":0,
   "name":"Contact Information",
   "fields":[  
      [  
         {  
            "alias":"NY County",
            "type":"drop",
            "required":0,
            "unique":0,
            "options":{  
               "add":[  
                  "Albany",
                  "Allegany",
                  "Bronx",
                  "Broome",
                  "Cattaraugus",
                  "Cayuga",
                  "Chautauqua",
                  "Chemung",
                  "Chenango",
                  "Clinton",
                  "Columbia",
                  "Cortland",
                  "Delaware",
                  "Dutchess",
                  "Erie",
                  "Essex",
                  "Franklin",
                  "Fulton",
                  "Genesee",
                  "Greene",
                  "Hamilton",
                  "Herkimer",
                  "Jefferson",
                  "Kings",
                  "Lewis",
                  "Livingston",
                  "Madison",
                  "Monroe",
                  "Montgomery",
                  "Nassau",
                  "New York",
                  "Niagara",
                  "Oneida",
                  "Onondaga",
                  "Ontario",
                  "Orange",
                  "Orleans",
                  "Oswego",
                  "Otsego",
                  "Putnam",
                  "Queens",
                  "Rensselaer",
                  "Richmond",
                  "Rockland",
                  "Saint Lawrence",
                  "Saratoga",
                  "Schenectady",
                  "Schoharie",
                  "Schuyler",
                  "Seneca",
                  "Steuben",
                  "Suffolk",
                  "Sullivan",
                  "Tioga",
                  "Tompkins",
                  "Ulster",
                  "Warren",
                  "Washington",
                  "Wayne",
                  "Westchester",
                  "Wyoming",
                  "Yates"
               ],
               "remove":[  

               ],
               "replace":[  

               ]
            }
         }
      ]
   ]
}

This is the JSON string you use to make it a drop-down list (note: it specifies type=”drop”). If you want to make it a multiple selection list instead, you would use type: “list”.

If your custom field already exists and you’re just adding more options, you can use a JSON string that looks just like this, however you would use the “PUT /objects/fieldeditor (https://api.ontraport.com/1/objects/fieldeditor)” API endpoint instead.

Populating an Ontraport Smart Form with Pilotpress Merge Fields without PHP

If you have a WordPress website using the Pilotpress plug-in, some functionality you may be interested in is populating an Ontraport form (whether it’s a legacy smartform or a form on an Ontrapage) using Pilotpress merge fields.

It turns out that you can’t simply put the Pilotpress merge fields in as the “value” attribute of the corresponding HTML form fields, or use them as the prefill values on the Ontraport form, or even set the form fields equal to the values of the corresponding merge fields directly by putting the merge fields into some Javascript variables. When the Pilotpress merge fields (which are actually WordPress shortcodes provided by the Pilotpress plugin) are put into places like these on a WordPress page, they don’t get processed (i.e., they show up as unprocessed, for example: “[pilotpress_field name=’First Name’]” ).

Unless you know how to write a little PHP code, doing it without PHP code requires a clever work-around (one that I didn’t come up with myself, but maybe I’m the first to apply it to Ontraport forms..?).

In short, what you want to do is put hidden DIV elements on your page that are filled with content using Pilotpress merge codes. You give them unique CSS IDs that you can use to then populate the Ontraport form on the page using some Javascript.

Here’s a simplified version of some form code you would see if you viewed the source HTML code of a form on your WordPress page or Ontrapage:

<form>
First Name: <input name="firstname" type="text" />
Last Name: <input name="lastname" type="text" />
Email: <input name="email" type="email" />
<input type="submit" value="Submit" />
</form>

You’ll see a bunch of other stuff when viewing the source code of one of your Ontraport forms; but the important thing to notice for our purposes is the “name” of each input field you want to pre-populate. In this case “firstname”, “lastname” and “email” are fields who values we want to populate. Note that inputs of type “submit” are the form submission buttons.

Say we want to pre-populate these three form fields using Pilotpress merge fields. The Pilotpress merge fields that correspond to these 3 fields (in order) are:

  • [pilotpress_field name=’First Name’]
  • [pilotpress_field name=’Last Name’]
  • [pilotpress_field name=’Email’]

However, as I mentioned, you can’t simply put these in a prefill values on your Ontraport forms; WordPress won’t process them and show their rendered values.

What you can do is add some hidden DIV elements–either on your WordPress page (in the WordPress editor’s “text” view) or in a custom HTML block on an Ontrapage like this:

<div style="display:none;" id="firstname">[pilotpress_field name='First Name']</div>
<div style="display:none;" id="lastname">[pilotpress_field name='Last Name']</div>
<div style="display:none;" id="email">[pilotpress_field name='Email']</div>

WordPress is going to process these merge fields/shortcodes, but you won’t see them on the page because they’re in invisible DIV elements (“display:none;”). But be assured, the actual first and last name of the logged in user–along with their email address–will in fact be there in the source code on the page.

But how do you get these into the form??

This is where you use a little Javascript magic to “pull” information from the invisible DIV elements and put them into the form/s on the page. You would put the following code into the HEAD section of the page if you can (it should work OK in a custom HTML block on an Ontrapage into which you inserted a form in the Ontrapage editor too):

<script>
window.onload = setVar;
function setVar() {
var theform = document.getElementsByTagName("form");
theform[0].elements["firstname"].value=document.getElementById('firstname').innerHTML;
theform[0].elements["lastname"].value=document.getElementById('lastname').innerHTML;
theform[0].elements["email"].value=document.getElementById('email').innerHTML;
}
</script>

This script is grabbing the content from the hidden DIV elements and putting it into the corresponding elements in the first form on the page (“theform[0]”). If you have more than one form on the page, the next form is “theform[1]” and so on.

Conclusion

I think the easiest way to pre-populate a form at a WordPress + Pilotpress website is using some PHP. However, the work-around described in this post is not a bad alternative if you don’t know PHP, don’t want to hire a PHP programmer, feel comfortable doing some HTML and Javascript coding, and/or don’t want to mess around with plug-ins to get the job done.

Caveats:

  1. Make sure to not let errant spaces get into your hidden DIVs–i.e., between the DIV tags and the merge fields–or these spaces will also get transferred to your form fields. For example, there should be no spaces on either side of the Pilotpress merge field code where these orange characters are: <div style=”display:none;” id=”firstname”>[pilotpress_field name=’First Name’]</div>
  2. This method works for Ontraport “Smart Forms”. It may not work with Ontraforms.
  3. If the form input fields also have ID attributes, make sure the IDs you use in your hidden DIVs don’t conflict with them (i.e., the IDs you use for the hidden DIVs must be unique on the page).

Record Contact Visit: A WordPress Plugin that works with Ontraport

I wrote a WordPress plugin that keeps a CSV log file at your website server of the cookied Ontraport contacts visiting your WordPress website. This plugin works in conjunction with Ontraport web page tracking.

The plugin records the following for each cookied visitor: 1) date & time of each visit (you specify the timezone), 2) the visitor’s Ontraport contact ID, and 3) the URL of each page visited.

This log file makes various analyses of contacts visits to your website/s possible; it also allows you to import data matching on contact ID in order to do things like give identified contacts a certain tag, add them to a campaign, add them to a sequence, etcetera.

Once you install the Record Contact Visit plugin, you will have a screen in your WordPress dashboard under Settings that looks like:

This dashboard screen gives you access to the CSV log file, as well as giving you a place to select the time zone you prefer used for the log’s date + time stamps.

Using the Plugin at your WordPress website

  1. You need to have an Ontraport account
  2. If you haven’t already, you need to install a Ontraport tracking script at your WordPress website–or alternatively, install the Pilotpress plugin
  3. Download the Record Contact Visit plugin
  4. Install and activate* the Record Contact Visit plugin
  5. Go to Settings > “Record Contact Visit” in the WordPress dashboard at the website where you’ll be using the plugin to modify the time zone (if you don’t want America/New York) and to view the contact visits CSV log file

Operational Notes

  • Log visits by contacts will immediately start being recorded as soon as you activate the plugin; if you don’t want to be using the America/New York time zone for date+time stamps, change that setting in the plugin ASAP.
  • If no Ontraport browser cookie exists for your website visitor (i.e., they haven’t filled out a form at your website; or they have, but now they’re using a different computer or browser), then the visit will not be recorded in the log file.
  • Please email me at mgm at WordPressAndOntraport.tech if you have any questions or run into any problems trying to install the plugin.

Customer Case Studies

I’m really interested to hear how people end up using the plugin. Please come back to this post and share your stories (as comments on this post) about how you’re the plugin to do interesting and creative things!


*Installing a downloaded zipped WordPress plugin file:

From the WordPress plugin menu click on Add New:

Instead of searching for a plugin you can directly upload your
plugin zip file by clicking on Upload:

Use the browse button to select the plugin zip file that was downloaded, then click on Install Now. The plugin will be uploaded to your blog and installed. It can then be activated (find it on the Installed Plugins page and click the “activate” link under the plugin called “Record Contact Visit”).

If you find this plugin useful and would like to encourage me to provide other useful plugins for Ontraport and WordPress, please consider sending your appreciation to my PayPal account 😀.

Dealing with Contacts with Multiple Email Addresses in your Ontraport Account

We’re constantly dealing with the issue of contacts with multiple email addresses in our Ontraport account and I’ve seen that others with Ontraport accounts are experiencing this problem too. It leads to at least a few issues:

  1.  Us getting charged extra by Ontraport for more contacts and/or messages to contacts than is necessary
  2. Contacts purchasing multiple products under different emails, so all their products don’t appear under one login
  3. Contacts getting multiple copies of a message we send out, or getting messages they shouldn’t because we filtered them properly on one of their addresses but not their other address/es

Now, one can go into the “Find and Merge Duplicates” function in Ontraport and find all the records with duplicate First + Last Names and do some merging. However:

  1. it’s not always clear which emails are related to the same person (there may be multiple people with the same first + last names)
  2. bulk email status isn’t displayed during merging(!!)**–AND if one of the statuses is Opt-out, the merged record is Opt-out!
  3. without feedback from the contact, it’s unclear which email address should be the *one* to use

I’m making this post so that others can share their strategies…and also to state a strategy I’ve just recently started using…

  • I’ve implemented a rule in Ontraport (in conjunction with an Ontraport API script) that checks for duplicate contacts with the same First + Last name each time a new contact record is added. When a duplicate is created, an email message is sent to our support email with a link to the duplicate contact records in Ontraport: it links to a search result in Ontraport on the first and last names.
  • As the support person, I check this list of contacts and determine if they seem to be the same person.
  • I then select all the contacts from the list that seem related and send them a saved email message I’ve created that says something like ” We have multiple email messages in our system for you. Please reply to this message with ‘Use this one’ if it would be OK for us to just use this email address to send messages to you”.
  • Not only does receiving a reply message from them insure I can send them messages from Ontraport using the replied-from email address, but it tells me which one to choose and which ones to delete out of our system.

This strategy may evolve and change over time, but this is what I’m trying for the time being.

If you have other strategies you have found effective for eliminating multiple email addresses for contacts in Ontraport, please share them as comments below!

**Since writing this, I discovered a work-around; you can add “Bulk Email Status” as a column for contact listings in Ontraport, so that when you go into the “Find and Merge Duplicates” function, it’ll show you the bulk email status for each contact before you select the contacts you want to merge.

 

 

 

 

 

Passing URL String Variables to Prefill an Ontraport Form

If you are using the “Javascript Snippet” method of getting a Ontraport Smart form onto your WordPress page and want to automatically fill in a field on the form (e.g., firstname) using a URL string variable (e.g., ?fn=John), I got it to work using the following Javascript:

<script>
function getParameterByName(name) {
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
results = regex.exec(location.search);
return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}
window.onload = setVar;
function setVar() {
var theform = document.getElementsByTagName("form");
theform[0].elements["firstname"].value=getParameterByName("fn");
}
</script>

Note: this assumes there’s one form on the page. If there are multiple forms on the page, the first one is referenced by theform[0], the second one by theform[1], etc.

Note 2: works with both visible and hidden form fields (I’m actually using it with a hidden field).

Note 3: make sure to put this script in the HEAD section of the page.

Integrating a WordPress Forum with Pilotpress Membership Levels

Let’s say you’ve created a membership website using Pilotpress (Ontraport’s WordPress membership plugin) and you would like to add a member forum. But you don’t just want a members-only forum (though you want that too) , you want to add multiple forums and/or sub-forums and have them be accessible only to certain Pilotpress membership levels–i.e., each forum/sub-forum can only be accessed by members in one or a few select Pilotpress membership levels.

When my company was still using the Wishlist Member membership plugin, the least expensive forum option we could find to work with WordPress and Wishlist Member was SimplePress. So, that’s what we used.

Upon moving from Wishlist Member to Pilotpress for our member website, we weren’t sure if SimplePress would still be our best option…though it would be easiest if we *could* make it work so we wouldn’t have to spend time configuring a new forum and trying to move posts and users to it.

Giving Pilotpress users access to SimplePress wasn’t a problem because new PilotPress logins generate new WordPress logins, and you can have SimplePress automatically assign new WordPress users/subscribers access to one or more forums.

The problem is you can only select one group to assign them to–i.e., you can select one group for all new members/subscribers to be assigned to.

But what if you want different Pilotpress membership levels to be assigned to different groups?…with only certain groups having access to certain forums/sub-forums? If we could come up with a way of doing this, we could continue to use the SimplePress forum plugin.

After digging into the SimplePress plugin code and doing some tests with the shortcodes provided by the PilotPress plugin, we developed a solution.

The Solution

First, we had to come up with a way to assign the currently logged in user to a previously set up SimplePress user group using a shortcode. So I developed a WordPress plugin that does just that. The shortcode it makes available looks like this:

[add_to_sp_group id=”19″]

..where id is the ID of the SimplePress group you want the user added to (the SimplePress group IDs are listed in SimplePress’s admin interface).

Second, we had to set up a way to assign users to SimplePress groups depending on their PilotPress membership level. We determined it could be done in conjunction with the PilotPress plugin in two ways:

  1. If there is a base/home page that only someone in a certain membership level can get to, and it’s a page that all users in that membership level have to pass through to get to any other of their protected pages, the “add_to_sp_group” shortcode can simply go on that page, and they’ll be added to the appropriate group upon visiting this page.
  2. The second method involves using the [show_if has_one=”Many,levels”] content [/show_if] shortcode provided by Pilotpress, on a page that all users logging into the member website have to pass through on their way to any other page in the membership website. For example:

[show_if has_one=”Gold”] [add_to_sp_group id=”3″] [/show_if]

…will assign the user to the SimplePress group with ID=3 if they are in the “Gold” Pilotpress membership level.

There is also a [remove_from_sp_group id=”3″] shortcode we made available in case there’s a reason to remove someone from a SimplePress group (for example: they moved to a new higher level membership and should not be participating in the forum at the lower membership level anymore).

BuddyPress Now Included Too!

Someone requested I include code in the plugin that works with the BuddyPress forum plugin. It turns out to be similar to what was needed for SimplePress, so new shortcodes for BuddyPress have been included too.

The new shortcodes are very similar to the shortcodes for SimplePress, except they use the abbreviation “bp” instead of “sp”. So, for example, to add someone to group with ID=4, you would use the following shortcode:

[add_to_bp_group id=”4″]

Requirements

The requirements to make this work are:

  • A WordPress website
  • An Ontraport account
  • Pilotpress installed at your WordPress website
  • SimplePress or BuddyPress installed at your WordPress website
  • The Forum Group Assign plugin installed* at your WordPress website
  • The creation of some forums or sub-forums and some groups in SimplePress or BuddyPress, along with assigning specific groups to specific forums
  • The creation of Pilotpress membership levels in Ontraport for the WordPress website

Once you’ve got all of these elements in place, you can start using the Forum Group Assign shortcode as described above.

If you find this plugin useful and would like to encourage me to provide other useful plugins for Ontraport and Pilotpress, please consider sending your appreciation to my PayPal account
( $5 / $10 / $15 )
..😀.

*Installing a downloaded zipped WordPress plugin file:

From the WordPress plugin menu click on Add New:

Instead of searching for a plugin you can directly upload your
plugin zip file by clicking on Upload:

Use the browse button to select the plugin zip file that was downloaded, then click on Install Now. The plugin will be uploaded to your blog and installed. It can then be activated (find it on the Installed Plugins page and click the “activate” link under the plugin called “Forum Group Assign“).

Smart Form Prefill: An Ontraport + WordPress Shortcode Plugin

I wrote a WordPress plugin that renders an Ontraport smart form at my WordPress website using a shortcode that looks like:

[op_smartform id=”1″]

..where id is the ID of the smart form in the Ontraport app. Using a shortcode to specify a form versus a javascript snippet is helpful for us in a couple of ways, one of which is that I don’t have to actually go into a form and then to “publish” to get the code from the Ontraport app, I just have to hover my mouse over the form link in the listing of forms to get the ID.

While I was at it, I added the additional feature that the form will automatically prefill with the user’s contact info if they have an Ontraport cookie at my website as the result of having filled out some other form at my website in the past (or if they’ve logged into Pilotpress). This automatic prefill feature is the default behavior of the shortcode.

If I don’t want the form to prefill and/or want the form to render faster (it takes a little longer for it to prefill, though it’s not too slow even then), I’ve added a “switch” to turn off prefilling:

[op_smartform id=”1″ prefill=”no”]

Using the Plugin at your WordPress website

  1. You need to have an Ontraport account
  2. It’s a good idea to install a Ontraport tracking script at your WordPress website–or alternatively, install the Pilotpress plugin
  3. In Ontraport, generate a new API Key for the website where you will be using the plugin (if you haven’t already)
  4. Purchase and download the Smart Form Prefill plugin (the order form is also at the bottom of this post)
  5. Install and activate* the Smart Form Prefill plugin
  6. Go to Settings > “Smart Form Prefill” in the WordPress dashboard at the website where you’ll be using the plugin and put in the API key codes from #3 above and save them.

Some Code Examples

• Render an Ontraport Smart Form with ID=4 and Prefill with Contact data if contact is cookied:

[op_smartform id=”4″]

• Render an Ontraport Smart Form with ID=4 and *don’t* Prefill with Contact data:

[op_smartform id=”4″ prefill=”no”]

Operational Notes

  • If no browser cookie exists for your website visitor (i.e., they haven’t filled out a form at your website; or they have, but now they’re using a different computer or browser), then the form will be rendered but not prefilled.
  • The plugin includes error messages if you forget to specify a form ID in your shortcode, or you specify one that doesn’t exist in your Ontraport account.
  • If you are creating and destroying browser cookies in the process of testing the shortcodes and they don’t seem to be working, make sure you clear the cache at your WordPress website if you are using one of those WordPress website caching plug-ins.
  • You only pay for the plugin once and will receive all/any future updates to the plugin.
  • Please email me at mgm at WordPressAndOntraport.tech if you have any questions or run into any problems trying to install the plugin.

Customer Case Studies

I’m really interested to hear how people end up using the plugin. Please come back to this post and share your stories (as comments on this post) about how you’re the plugin to do interesting and creative things!


*Installing a downloaded zipped WordPress plugin file:

From the WordPress plugin menu click on Add New:

Instead of searching for a plugin you can directly upload your
plugin zip file by clicking on Upload:

Use the browse button to select the plugin zip file that was downloaded, then click on Install Now. The plugin will be uploaded to your blog and installed. It can then be activated (find it on the Installed Plugins page and click the “activate” link under the plugin called “Smart Form Prefill”).

The Order Form