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.

In previous blog posts, we showed you how to build a mortgage calculator, a quote calculator, and an insurance calculator! 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 GravityMath plugin.

Let’s get started!

**Download the free ROI calculator template now!**

Import the template into Gravity Forms and customize as necessary.

## What you’ll need

To build a simple ROI calculator, all you need is Gravity Forms. However, if you want to build a more advanced ROI calculator that displays the annualized rate of return, you’ll need both Gravity Forms and GravityMath.

We’ll show you how to build both types of calculators below!

## 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.

Here’s a simple example: Let’s say you invested $2,000 in a company called Floaty Corp in 2022 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`

Finally, multiple the result by 100 to get a percentage. In this case, your ROI would be 25%.

## 1. Build a simple ROI calculator using Gravity Forms

Gravity Forms enables you to do calculations using form field inputs.

To create a new form hover “Forms”* *in the left-hand WordPress menu and click “Add New”. Now you can start adding field to your form using the Gravity Forms drag and drop editor. To build a simple ROI calculator form, your form only needs to have three fields.

First, add two “Number”* *fields—one labeled “Investment” and one labeled “Return”. Next, add a third Number field labeled “ROI”.

Here’s where things get interesting. Open the field setting for the third field and check the box that says “Enable Calculation”. Inside the text editor, you can use field 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. (Feel free to copy and paste this calculation, just ensure you replace the merge tags with your own).

`({Return:2} - {Investment:1}) / {Investment:1} * 100`

💡 **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 type values into the “Investment” and “Return” fields, you’ll see the “ROI” field automatically populate with 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. Next, we’re going to show you how to calculate the annualized rate of return, and build a more advanced ROI calculator using the GravityMath plugin.

## 2. Build an advanced ROI calculator using GravityMath

GravityMath allows you to perform advanced calculations using Gravity Forms field values using the powerful `[gv_math]`

shortcode, like so:

```
[gravitymath] 5 * 10 [/gravitymath]
Output: 50
```

You can also use Gravity Forms merge tags to do calculations based on user inputs! `[gravitymath]`

also 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 by writing a calculation that outputs 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:

This formula requires a third variable that isn’t needed for simple ROI calculations. Bevause of this, we’ll need to create an updated form with the following fields:

- Starting value of investment (“Number” field)
- Ending value of investment (“Number” field)
- Number of years (“Number” field)

Next, we’ll need to decide where to show the calculation result. GravityMath does not allow you to output calculations *inside* a form. Instead, we’ll display the calculation inside the confirmation message. To add a new confirmation, edit your form, hover over “Settings”*,* click on “Confirmations” and then “Add New”. make sure to select “Text” as the confirmation type.

In the text editor, copy and paste the below formula for annualized rate of return:

`[gravitymath] round( (pow( ({Ending value of investment:2}/{Starting value of investment:1}), (1/{Number of years:3}) ) - 1) * 100, 2 ) [/gravitymath]%`

When you copy and paste the formula, make sure to replace the merge tags with your own!

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

And after clicking “Submit”, this is what we see…

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

💡 **Pro tip**: The `[gravitymath]`

shortcode can be used anywhere on your website, including inside Gravity Forms notifications and confirmations!

## 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 WordPress 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 GravityMath plugin. (So no need to install a separate ROI calculator WordPress plugin!).

To get started with advanced calculations for WordPress and Gravity Forms, get GravityMath today!

## Helpful tips right in your inbox.

Subscribe to our weekly newsletter for tips, special offers, and more!

## Helpful tips right in your inbox.

Subscribe to our weekly newsletter for tips, special offers, and more!