Using Ultimeter With 3rd-Party Data

With the help of filters, you can connect Ultimeter with any 3rd-party source. This article introduces the 3 different filters, explains what you need to do to get Ultimeter to work with your chosen data.

The Filters

Ultimeter has three filters, one for each of the standard goal formats – currency, percentages and custom units. They are:

$current = apply_filters('ultimeter_filter_currency_progress', $current);
$current = apply_filters('ultimeter_filter_percentage_progress', $current);
$current = apply_filters('ultimeter_filter_custom_progress', $current);

If you are unfamiliar with hooks, we encourage you to read the basics here: https://www.wpbeginner.com/glossary/hooks/

The easiest way to explain the filters is to use a real world example. You have installed a Forms plugin, that simply allows users to fill out a form on your site, each time they see a rare parrot in their back garden. When you reach 100 forms (or parrot sightings), you will reward the 100th bird-watcher with a gold medal.

You know that you need to be able to see the real-time number of sightings, so you speak to the developers of the Forms plugin. They tell you that there is a function included in the code that counts the number of forms received for each form, and spits out the total. Let’s call it:

getTotalNumberOfSubmissions( $id ) 

At this stage, you don’t really need to know how the Forms plugin calculates the total. All the developers said was to swap ‘$id’ for the ID number of the form you want (you remember this was ‘1’), and that was it.

So, how do we connect the function you’ve been given, with Ultimeter?

Joining the Dots

First head to your functions.php file. This is where you insert all sorts of custom code. It’s a really useful bit of kit, and you will be using it heaps while you set up your website. Here’s a brief intro from the WordPress team: https://codex.wordpress.org/Functions_File_Explained.

We want the custom units filter, as we will be counting bird sightings, not Dollars or a percentage. Let’s type our filter at the end of our functions.php file:

function countSightings( $current ) {
    $current = getTotalNumberOfSubmissions( 1 );
    return $current; 
}
add_filter('ultimeter_filter_custom_progress', 'countSightings');

If you were to check your Ultimeter now (assuming you have correctly set it up to measure custom units, and entered something like ‘Bird Sightings’ into the custom units box), you should see the correct number of sightings being tracked. Even better, the filter will continue to update as new forms are submitted.

It Isn’t Working!

As an Ultimeter customer, we are able to provide you with support for the filter itself, but not the bit in the middle. We won’t be able to assist with the code that gets the data from your 3rd-party source. We wish we were experts in every one of the millions of plugins and data sources available, but sadly we aren’t.

If you require further help in setting up your custom data source, any web developer should be able to assist, or get in contact with us directly and we will give you a quote. We will check your Ultimeter is set up correctly at the same time, and if we determine that the problem was the filter after all, you won’t pay a thing.

Was this helpful?