Embed the calculators
The calculators
Each has its own address and its own value for the loader's data-widget attribute.
| Calculator | data-widget | iframe address | Presets |
|---|---|---|---|
| Mortgage Calculator | mortgage | https://www.usmortgagecalc.com/embed/mortgage-calculator | state, price, rate |
| Property Tax Calculator | property-tax | https://www.usmortgagecalc.com/embed/property-tax-calculator | state |
| Refinance Calculator | refinance | https://www.usmortgagecalc.com/embed/refinance-calculator | none |
| Closing Cost Calculator | closing-cost | https://www.usmortgagecalc.com/embed/closing-cost-calculator | state |
The earlier address https://www.usmortgagecalc.com/embed/calculator still works and is the mortgage calculator, so existing embeds do not need to change.
Installation
Three ways in. The first two use a small script that builds the frame and keeps it the right height; the third needs no script at all.
1. Script tag
One tag. The calculator appears directly after it, wherever you place it.
<script
src="https://www.usmortgagecalc.com/embed.js"
data-widget="mortgage"
></script>2. Div and script
Mark the spot with a div and load the script anywhere after it. Use this when your editor copes better with a div than with a script in the middle of the content. You can use both forms on one page, and several calculators on one page.
<div data-usmc-calculator data-widget="mortgage"></div>
<script src="https://www.usmortgagecalc.com/embed.js" async></script>3. Plain iframe
For platforms that strip JavaScript, such as many hosted CMSs and newsletter tools. No script runs on your page and the frame does not resize itself, so give it room: see sizing.
<iframe
src="https://www.usmortgagecalc.com/embed/mortgage-calculator"
title="Mortgage Calculator"
width="100%"
height="1100"
loading="lazy"
style="border:0;"
></iframe>Swap mortgage for property-tax, refinance or closing-cost in the first two forms, or change the iframe address to the calculator you want. A data-widget the loader does not recognise shows the mortgage calculator.
Presets
A regional site should not open on a blank state field. These are the only presets there are.
<!-- Opens on Texas, with a $450,000 price and a 6.5% rate filled in -->
<script
src="https://www.usmortgagecalc.com/embed.js"
data-widget="mortgage"
data-state="Texas"
data-price="450000"
data-rate="6.5"
></script>
<!-- The same presets in the plain iframe form -->
<iframe
src="https://www.usmortgagecalc.com/embed/mortgage-calculator?state=Texas&price=450000&rate=6.5"
title="Mortgage Calculator"
width="100%"
height="1100"
loading="lazy"
style="border:0;"
></iframe>| Attribute | iframe parameter | Works on | Value |
|---|---|---|---|
data-state | state | Mortgage, property tax, closing cost | Full state name, such as Ohio or North Carolina |
data-price | price | Mortgage | Home price in dollars, digits only |
data-rate | rate | Mortgage | Annual interest rate as a percent, such as 6.5 |
- The refinance calculator takes no presets.
- The mortgage calculator shows a result on load only when it has both a state and a price; with just one it fills the field and waits for the visitor.
- State names must be written out in full, exactly as in the calculator's own list. An abbreviation such as
TXis not recognised. - The attributes work on the script tag or the div. No other attribute or parameter is supported.
Responsive behavior and sizing
The calculators are responsive. How tall their frame should be depends on how wide it is.
On a wide frame, roughly 1,024 pixels and up, the form and the result sit side by side. On anything narrower, which includes a typical article column and every phone, they stack into one column and the calculator gets taller. The frame is always 100% of the width you give it, and the content did not scroll sideways at any width tested, from 360 pixels up.
Automatic height (script forms)
With the script, the calculator tells your page how tall it is whenever its content changes, for example when a result appears, and the loader resizes the frame to match. There is no inner scrollbar and no empty gap. The only message the frame sends to your page is that number, and the loader only accepts it from this site and only for frames it created. Frames begin at 720 pixels, then correct themselves as soon as the calculator reports.
Fixed height (iframe form)
A plain iframe cannot resize itself, so set a height that fits. These were measured before a result is shown; results make the calculator taller, and a visitor will see an inner scrollbar if the frame is too short. When in doubt, go taller, or use a script form.
| Calculator | Column about 700 px or wider | Narrow column (about 360 px) |
|---|---|---|
| Mortgage Calculator | 1100 px | 1600 px |
| Property Tax Calculator | 850 px | 950 px |
| Refinance Calculator | 1200 px | 1500 px |
| Closing Cost Calculator | 1400 px | 1700 px |
WordPress and other CMSs
In WordPress's block editor, add a Custom HTML block and paste either script form. If a theme or security plugin strips script tags, use the iframe form, which needs none. The same rule applies to any editor: if it removes <script>, use the iframe. Some editors only run scripts on the published page and show an empty box in their preview; publish, or check the live page, before concluding it does not work.
<!-- Block editor: add a "Custom HTML" block and paste either form -->
<div data-usmc-calculator data-widget="property-tax" data-state="Texas"></div>
<script src="https://www.usmortgagecalc.com/embed.js" async></script>
<!-- If your theme or a security plugin strips <script>, use the iframe form -->
<iframe
src="https://www.usmortgagecalc.com/embed/property-tax-calculator?state=Texas"
title="Property Tax Calculator"
width="100%"
height="850"
loading="lazy"
style="border:0;"
></iframe>Single-page apps
The loader scans the page once, when it loads. If your framework renders the div later, for example on a client-side route change, call window.usmcEmbed.mount() after it appears. Calling it again is safe; a calculator that is already mounted is skipped.
<!-- Single-page apps: add the div when the route renders, then ask the loader to mount it -->
<div data-usmc-calculator data-widget="property-tax" data-state="Ohio"></div>
<script>
// The loader runs once at page load. If your framework inserts the div later:
window.usmcEmbed && window.usmcEmbed.mount();
</script>Attribution
Every calculator ends with a small line, Powered by USMortgageCalc, linking to usmortgagecalc.com. It is how the calculators stay free to offer, and we ask that you leave it in place. The link is part of the calculator inside the frame, so it is not a link from your page and asks nothing of your page's markup. We are not asking you for a link, or for any particular kind of link, and we make no claim that embedding has any effect on search rankings.
Privacy and usage reporting
What the widget does with your visitors, stated exactly.
- No cookies, no storage. The frame sets no cookies and uses no localStorage or sessionStorage.
- Inputs stay in the browser. The calculation runs in the visitor's browser, and nothing they type, and nothing it calculates, is sent anywhere.
- No ads and no third-party scripts in the embedded calculator.
- It reads nothing from your page. It does not access your page's content, cookies or storage, and the only message it sends to your page is its own height.
- Ordinary request details. As with any hosted resource, our servers receive standard request information, such as an IP address, when the frame loads.
- Aggregate usage counts. To learn whether the calculators are used, the script reports that a widget loaded, and the calculator reports four things: that it was seen, started, completed, or that its attribution link was clicked. Each report is the event name, which of the four calculators it was, and the hostname of the page that embeds it. It contains nothing a visitor typed, no identifier, and no part of your page's address beyond the hostname. A visitor whose browser sends Do Not Track or Global Privacy Control is not counted.
These counts are collected by our own counter, not by an advertising or analytics service, and they are floors: a visitor who blocks the request is missing from them.
Troubleshooting
Most problems are one of these.
Nothing appears, or there is an empty box.
Check the page's source for the script and the div. An editor that strips script tags removes the script form entirely; switch to the iframe. If your site sets a Content-Security-Policy, it must allow this site for scripts and frames (see below). Open the browser's developer console: a blocked script or frame is reported there by name.
It shows the mortgage calculator, not the one I chose.
The loader falls back to the mortgage calculator when data-widget is missing or not one of mortgage, property-tax, refinance or closing-cost. Check the spelling, and that it is in lower case with a hyphen.
My preset is ignored.
Write the state name in full, such as New Jersey. Presets exist only for the calculators in the presets table, and data-price and data-rate apply to the mortgage calculator only. The mortgage calculator also needs both a state and a price to show a result on load.
There is an inner scrollbar, or a gap under the calculator.
The frame height does not match the content. Script forms fix this on their own; check that the script is not blocked. For a plain iframe, use a taller height, especially in a narrow column.
It works on the published page but not in the editor preview.
Some editors do not run scripts in their preview. Publish, or open the live page, to test.
The calculator appears twice, or not after I navigate.
In a single-page app, call window.usmcEmbed.mount() once after the div renders. It skips calculators that are already mounted, so calling it again is harmless.
Content-Security-Policy
If your site sends a CSP header, allow this site as a script source (for the loader) and a frame source (for the calculator). The iframe form needs only the frame rule. If your policy also restricts connect-src, the loader's anonymous “widget loaded” report is blocked and logged in the console; the calculator itself still works.
Content-Security-Policy:
script-src 'self' https://www.usmortgagecalc.com;
frame-src 'self' https://www.usmortgagecalc.com;Frequently asked questions
Is it free?
Yes. The calculators are free to put on your site, with no fee and nothing to sign up for.
Do I need an account?
No. There is nothing to sign up for and no key to request. Paste the code and it works.
Can a business use it?
Yes. Agents, brokers, publishers and housing sites are the intended audience, and commercial sites are welcome. As with any content on your site, you are responsible for how it fits your own policies and any rules that apply to your business. The calculators give estimates, not loan offers.
Does it work on mobile?
Yes. Each calculator is responsive and was checked from phone-width columns up to full desktop width. In a narrow column the form stacks into a single column and the frame grows taller, which the script versions handle automatically.
Does the calculator work in an iframe?
Yes. The calculators are built to run inside an iframe on another site. The script version creates the iframe for you and keeps its height matched to the content; the plain iframe version needs no script on your page at all.
Does the widget collect user data?
The widget sets no cookies and uses no localStorage or sessionStorage, runs no ads, and loads no third-party tracking scripts. Calculations happen in the visitor's browser, and the numbers a visitor types are not sent anywhere. Like any hosted resource, our servers do receive the ordinary request details (such as IP address) when the frame loads. We also count usage in aggregate: the script reports that a widget loaded, and the calculator reports that it was seen, started, completed or that its attribution link was clicked. Each report carries only that event name, which calculator it was and the hostname of the page that embeds it (and, if your embed code includes a partner id we gave you, that id, so we can report usage to you), and nothing a visitor typed or any identifier. Visitors whose browsers send Do Not Track or Global Privacy Control are not counted.
Can I customize the calculator?
Only in the ways documented here: you can choose which calculator to show, open it on a state, and for the mortgage calculator preset a price and an interest rate. There are no options for colors, fonts or layout, and the size is whatever column you give the frame.
Will the calculator update automatically?
Yes. The widget is served from USMortgageCalc, so a correction or improvement made here reaches every site that embeds it without you changing anything.
How does the attribution work?
Each widget carries a small “Powered by USMortgageCalc” line under the calculator, linking to this site. We ask that you leave it in place; it is the only thing we ask in return. The link sits inside the frame, so it is not a link from your page and does not require anything of your page's markup. We do not ask for, and make no promises about, any search benefit.
Rather build your own?
The calculators are a convenience, not the only route. The REST API returns the same calculations as JSON so you can render them in your own design, and the datasets are downloadable under CC BY 4.0 if you only need the numbers. Questions, or a calculator you would like to see? Get in touch. All figures are estimates, not loan offers or financial advice.