How can I track conversions occurring in third-party websites?

Nelio A/B Testing is a plugin specifically designed for WordPress. Its aim is to make A/B Testing in WordPress extremely easy. However, this entails some limitations: as soon as one of your visitors leaves WordPress and accesses an external page, Nelio A/B Testing can no longer track her activity.

Even though usually this is not a problem as all events tend to occur in WordPress, there are some scenarios in which the conversion occurs outside. One typical example is an e-commerce system, where the checkout process is performed outside WordPress. Let’s see a few solutions to this problem.

Method 1. Using “External Page” Conversion Actions

If you’re interested in tracking the fact that a user visited an external page, the easiest way to do so is by using External Page conversion actions. Using this conversion action, you can specify the URL that should trigger a conversion.

However, there’s a catch: the conversion action doesn’t actually test “a visit to the external page”, but rather the fact that “the user click on a link that will take her to that external page.” As a result, this conversion action will only work if there’s a direct link from your WordPress site to the external page and might not be exactly measuring what you want (but it’s close enough).

Method 2. Redirecting your visitor back to WordPress

The easiest solution to overcome the fact that a user “left” your WordPress site and, therefore, you cannot track whether she fulfilled your conversion action or not is to redirect her back to WordPress once she’s converted. For instance, consider the following scenario:

  1. A visitor decides to buy a product or service you’re offering in your WordPress site.
  2. She then clicks on Buy and she goes to an external page called http://external.com/checkout/, where she’ll have to fill a form with some payment details.
  3. Once she’s completed the form, she checks-out and the purchase is completed. The user is now in http://external.com/purchase-completed/.

In order to know that the purchase has been successful, we could add a redirection in http://external.com/purchase-completed page/ and send the user back to our WordPress site. You might be able to do this using the External website setup options or, if you have access to its source code, by adding a simple JavaScript such as:

<script type="text/javascript">
window.location = 'https://your-wordpress-site.com/thank-you/';
</script>

which redirects the user to a Thank You page in your WordPress site.

If you now use this Thank You page in your test (using a Page View conversion action) you’ll be able to track a conversion that occurred outside WordPress.

Please note this Thank You page can be an already existing page or a page you specifically created for tracking that conversion.

Please also note that the page should not be accessible from anywhere else, or you’d be counting conversions that could have never occurred.

Method 3. Using custom JavaScript events

If you have access to the source code of the external page, you can use a Custom JavaScript Event conversion action:

Conversion action with a customized JavaScript event
Conversion action with a customized JavaScript event

As you can see in the previous screenshot, a conversion action of this type requires two scripts:

  • First, you’ll need to add Nelio A/B Testing’s external tracking script. This script can be found in https://your-wordpress-site.com/wp-json/nab/v1/external.js.
  • Then, you simply need to call the method convert in the nab object whenever a conversion occurs. convert takes two arguments, which have already been preset for you by Nelio A/B Testing.
'),document.contains||document.write(''),window.DOMRect||document.write(''),window.URL&&window.URL.prototype&&window.URLSearchParams||document.write(''),window.FormData&&window.FormData.prototype.keys||document.write(''),Element.prototype.matches&&Element.prototype.closest||document.write('')