How to build a Gravity Forms ROI calculator

How to Build a Gravity Forms ROI Calculator

Written by Casey Burridge

Last updated:

Categories Math by GravityView

Gravity Forms is more than just a form plugin. It’s a powerful way to collect, process, and output information on your WordPress website. In fact, by making use of advanced features, you can turn your forms into powerful calculators.

There are endless ways to leverage Gravity Forms calculations on your WordPress website. In previous blog posts, we showed you how to build a mortgage calculator and a quote calculator. And in this post, we’re going to show you how to build an ROI calculator.

ROI is an important business metric, especially for marketing and sales. We’ll start off by showing you how to build a simple ROI calculator using Gravity Forms’ built-in features. Next, we’ll build a more advanced calculator using the Math by GravityView plugin.

Let’s get started!

What Is ROI?

ROI stands for “Return on Investment”. It’s an important business metric that’s often used to gauge the profitability of investments or the effectiveness of advertising campaigns. 

Your ROI tells you how much money you’re making relative to the amount you’ve invested. ROI is expressed as a ratio or percentage.

How to Calculate ROI

Calculating ROI is simple. All you need to do is subtract the cost of your investment from the current value of the investment and divide that number by the cost.

The formula to calculation ROI (ROI = Value of Investment minus Cost of Investment divided by Cost of Investment)

Here’s a simple example. Let’s say you invested $2,000 in Floaty Corp. in 2019 and you sold your shares this year for $2,500. To calculate the return on your investment (ROI), you would subtract the initial cost from the final value and divide that number by the cost.

$2,500 – $2,000 / $2,000 = 0.25 (25%)

In this case, your ROI would be 25%.

ROI Calculations Using Gravity Forms

Gravity Forms enables you to do calculations using form field inputs. Here’s a simple ROI calculator example using Gravity Forms’ built-in calculation features.

Make a Simple ROI Calculator

Start by hovering over Forms in the left-hand WordPress menu and clicking Add New. To create a simple ROI calculator, your form only needs to have three fields.

First, add two Number fields – one called “Investment” and one called “Return”.

Next, add a third Number field called “ROI”. Here’s where things get interesting. Under Field Settings check the box that says “Enable Calculation”. Inside the text editor, you can use merge tags to write a formula that calculates the ROI based on the values entered by the user.

Here’s the calculation. As you can see, it’s relatively straightforward.

The formula for ROI inside the Gravity Forms "Enable Calculation" text box

Pro tip: To ensure your calculation is valid, click the link that says “Validate Formula”.

Now, when you open your form on the front end and input values for the Investment and the Return, you’ll see the “ROI” field automatically populates with the ROI percentage.

A Gravity Form on the front end displaying the ROI percentage

Now that you know how to calculate ROI, you can apply this concept to build your own ROI calculator with fields that are specific to you and your business. But don’t leave just yet! Because next, we’re going to show you how to implement a more advanced ROI calculator using the Math by GravityView plugin.

Advanced ROI Calculator Using Math by GravityView

Math by GravityView allows you to do advanced calculations using Gravity Forms field values. So no need to install a separate ROI calculator WordPress plugin!😉

If you have a GravityView All Access license, you can install Math by GravityView from inside your WordPress dashboard. Hover over Views, click Manage Add-Ons, scroll down to Math by GravityView and click Install.

The GravityView "Manage Add-Ons" screen

Math by GravityView allows you to perform advanced calculations using the [[gv_math]] shortcode, like so:

[gv_math] 5 * 10 [/gv_math]
Output: 50

You can also use Gravity Forms merge tags to do calculations based on user inputs. [gv_math] gives you access to mathematical operations and functions, allowing you to create a more advanced ROI calculator.

Let’s take a look at an example.

Calculating the Annualized Rate of Return

Let’s create a form that calculates the annualized ROI, also called the annualized rate of return. This is a metric that’s harder to calculate as it requires more complex mathematical operations.

While ROI gives you the overall return on your investment, the annualized rate of return is a way of calculating investment returns on an annual basis. Calculating the value of an investment over time is known as the rate of return.

Investors use the annualized rate of return as a metric to compare the profitability of different investments over the same time period. Here’s the formula to calculate the annualized rate of return:

The formula for calculating the Annualized Rate of Return

You may have noticed this formula requires an extra variable called Number of Years. We’ll need to update our form to account for this.

Next, you’ll need to decide where to show the calculation result. The [gv_math] shortcode can be used anywhere on your website, including inside Gravity Forms notifications and confirmations!

For this example, we’ll display the calculation inside the confirmation message. To add a new confirmation, edit your form, hover over Settings, and click on Confirmations. Next, click on Add New.

In this text editor, copy and paste the formula for annualized rate of return. Although the formula is complex, it’s easy to implement using the [gv_math] shortcode:

[gv_math] round( (pow( ({Return:6}/{Investment:8}), (1/{Years:10}) ) - 1) * 100, 2 ) [/gv_math]%
The formula for calculating the annualized rate of return inside the Gravity Forms confirmation message

You can copy and paste this formula for use in your own calculator app (just remember to replace the merge tags). 

Okay, the final step is to test our form on the front end. First, we’ll input some values…

A Gravity Form on the front end with inputs for the Starting Value of Investment, Ending Value of Investment and Number of Years

And after clicking submit, this is what we see…

Gravity Forms Confirmation message that says "Your annualized rate of return is: 18.92%"

Awesome! It’s working (If you want to be sure, you can grab a calculator to verify). 

Gravity Forms ROI Calculator: Wrapping Up

ROI stands for Return on Investment, it’s a popular business metric for measuring the profitability of an investment. It’s also used in marketing to measure the effectiveness of advertising campaigns.

Using Gravity Forms, you can build an ROI calculator for your website. And if you want to take things further and calculate the annualized rate of return or other more complex metrics, you can use the Math by GravityView plugin.

To get started with advanced calculations on your WordPress website, get Math by GravityView today!

Join Our Newsletter!📧🙌

✔️ New blog posts straight to your inbox

✔️ Be the first to hear about new updates and releases