=== Dealroot ===
Contributors: leadwon
Tags: utm, lead tracking, attribution, gclid, google ads
Requires at least: 6.8
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 0.31.1
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

See which ads, searches and websites bring you enquiries, follow every lead to a sale, and get it on Telegram the moment it arrives.

== Description ==

Most small businesses know how many visitors they get, but not which of them became customers. Dealroot closes that gap without a CRM.

When someone sends one of your forms, Dealroot stores the enquiry with how that person found you: the ad, the search engine, the social post or the website that linked to you. Mark the lead as contacted, won or lost with its value, and see which channels earn you money. You do not need to run ads: organic search, social media, AI assistants, newsletters and referrals are tracked from the first visit.

= What you get =

* **Leads to follow up** – an overview of what waits for an answer, every lead in a list or on a board, and a timeline from the first visit to the sale.
* **25 form plugins and page builders** – see the list below. A form scan finds every form on your site, also those built without a form plugin.
* **The source of every enquiry** – UTM parameters and click IDs of Google, Microsoft, Meta, TikTok, LinkedIn and more, the referrer and the landing page, for the first and the latest visit, sorted into channels that make sense worldwide.
* **Reports with charts** – revenue next to ad costs, enquiries and customers by channel, campaign, page, form, device and city, when enquiries arrive and how fast you answer, for any period and as a PDF.
* **Phone, WhatsApp and email clicks** – counted per channel, so a call can still be credited to its ad.
* **Form analytics** – how many visitors start and send each form, and at which field the others give up. Only anonymous daily totals are stored.
* **Live view and map** – who is on your site right now, and where your visitors and leads come from.
* **AI assistant, one switch** – every enquiry summed up, sorted and checked for spam, drafts of your answers, a confirmation within a minute, and questions about your leads in plain words. Optional, see External services.
* **Telegram and webhooks** – every new lead on your phone, or in Make, Zapier, n8n or your own system.
* **WooCommerce and other shops** – paid orders become won deals with their source.
* **Offline conversions** – won leads exported in the format Google Ads, Microsoft Advertising and Meta import.
* **Privacy** – first-party cookie only, optional wait for cookie consent (WP Consent API or your own banner), data retention and the WordPress personal data tools.

= Dealroot Pro =

Everything above is free and stays free. [Dealroot Pro](https://dealroot.net/pricing/) is an add-on for businesses that advertise and work with a CRM:

* **Conversions to Google Ads, Microsoft Advertising and Meta** – leads you mark as qualified or won are reported with the deal value to the platform that brought the visitor, so the ads learn which clicks become customers.
* **Ad spend and return on ad spend** – costs are imported from Google Ads, Microsoft Advertising and Meta every hour, for the cost per lead, the cost per customer and the return on ad spend of each channel, source and campaign.
* **Profit, not only revenue** – margins per product category or the cost of goods in WooCommerce, for the profit on ad spend.
* **CRM and email marketing** – HubSpot, Pipedrive, monday.com, Zendesk Sell, Insightly, Nutshell, Bitrix24, Brevo and Mailchimp, connected with one click or one key, in both directions. Any other CRM by webhook.
* **Spam filter** – sales pitches and bot submissions are put aside automatically.
* **Team and reminders** – owners, follow-up dates, reminders, and new leads in Slack or Microsoft Teams.
* **For agencies** – all client sites on one screen, white label and a monthly report for each client.

[Compare the plans](https://dealroot.net/pricing/)

= Supported form plugins =

* Contact Form 7, WPForms, Gravity Forms, Fluent Forms, Ninja Forms, Formidable Forms, Forminator, JetFormBuilder, Everest Forms, WS Form, SureForms, MetForm, HappyForms and Jetpack Forms
* Elementor Pro, Divi, Bricks, Beaver Builder, Thrive, Kadence Blocks, Spectra and Otter Blocks
* Mailchimp for WordPress, MailPoet, Ultimate Member and the WooCommerce checkout
* Embedded HubSpot and Tally forms with the answers; Typeform and Calendly with their source
* Any other HTML form: tick it after the form scan, or add `data-dealroot` to the form tag
* Custom code via `do_action( 'dealroot_capture', $form_id, $form_name, $fields )`

= Translations =

English, German, French, Spanish, Italian, Dutch, Polish, Ukrainian and Russian are included.

= Credits =

The Dealroot screens use the Geologica typeface by the Geologica Project Authors, licensed under the SIL Open Font License 1.1, included in the plugin.

== Installation ==

1. Install and activate the plugin.
2. Open **Leads → Forms** and click **Scan site**. Untick forms that are not enquiries and save.
3. Go to **Leads → Settings** and choose how to handle cookie consent.
4. Optional: connect a Telegram bot to get notified about new leads.
5. Submit one of your forms through a link such as `https://example.com/?utm_source=test&utm_medium=cpc` and open **Leads → All leads**.

== Frequently Asked Questions ==

= Do I need to change my forms? =

No. Dealroot reads the tracking cookie when a supported form plugin processes a submission. No hidden fields are needed.

= Do I need Google Ads or another ad account? =

No. The reports show which search engines, social networks, AI assistants, newsletters and websites bring you enquiries and customers, with or without ads. Ad accounts only matter if you want to send won deals back to them.

= Which forms are saved as leads? =

Every form of a supported form plugin, unless you untick it under Leads → Forms. Other forms are saved once you tick them there after a scan. Forms embedded from other services, such as Calendly or Typeform, run on their servers and are listed for your information only.

= Does it work with caching plugins and CDNs? =

Yes. The tracking script runs in the visitor's browser, so cached pages are tracked correctly.

= Is it GDPR compliant? =

Dealroot stores data only in your own WordPress database and sends nothing to third parties. Campaign tracking cookies usually require consent in the EU, so enable one of the consent options under Leads → Settings. Dealroot also suggests text for your privacy policy under Settings → Privacy.

= How do I add the lead source to my notification email? =

Add `{dealroot_attribution}` to the notification email of your form. It works with every form plugin. `{dealroot_channel}`, `{dealroot_source}` and `{dealroot_campaign}` insert single values. Contact Form 7 also offers `[_dealroot_attribution]` in its mail tag list.

= Does it count calls and WhatsApp messages? =

Dealroot counts clicks on phone, WhatsApp, email, Telegram, Viber and map links and attributes them to the channel the visitor came from. It cannot know whether the call was answered, so clicks are reported separately from leads.

= How do I send won deals to Google Ads? =

Your existing conversions, for example form submissions counted by the Google tag, cannot receive uploaded sales, so you create one more conversion of the type "Import → Track conversions from clicks". Leads → Settings → Sales shows each step and the name to paste, for Google Ads and for Microsoft Advertising. Then use **Export conversions** on the Leads screen and upload the file in Google Ads under Goals → Conversions → Uploads. Dealroot Pro does all of this automatically.

= Can I capture a form from my theme or page builder? =

Yes. Scan your site under Leads → Forms and tick the form, or add `data-dealroot="Quote request"` to the `<form>` tag. Dealroot then saves the submission in the background without changing how the form works.

= Can I get leads on WhatsApp? =

Connect a webhook to Make, Zapier or n8n and add a WhatsApp step there. Each lead also has a WhatsApp button that opens a chat with the person.

= How do I watch the Clarity recording of a lead? =

Add Microsoft Clarity to your site, with its WordPress plugin or the tracking code. Dealroot finds it on its own: open a lead and click "Watch in Microsoft Clarity". Clarity keeps recordings for 30 days unless you mark them as favourites. In Clarity, the smart events dealroot_form_sent and dealroot_contact_click show all visits that ended in an enquiry.

= Is it only for one country? =

No. Currency and phone country follow your site language (or WooCommerce), dates and amounts are shown in each user's language, the admin works in right-to-left languages, and the channel rules know the main search engines and social networks of Europe, the Americas, Asia and the CIS.

= Can I capture a form with custom code? =

Yes:

`do_action( 'dealroot_capture', 'quote-form', 'Quote request', array( array( 'label' => 'Email', 'type' => 'email', 'value' => $email ) ) );`

== External services ==

Dealroot stores leads, visits and contact clicks in your WordPress database. Nothing is sent anywhere unless you turn on one of the features below.

= Telegram =

When you connect Telegram under Leads → Settings, your site talks to the Telegram Bot API (api.telegram.org) with the bot token you enter. Every new lead is sent to the chat you choose, with the lead's name, email address and phone number, the form, how the visitor found your site and the message they wrote; "Send test message" sends a sample the same way. Your site also sets itself as the webhook of the bot, so Telegram passes on what you write or press in that chat: buttons, replies, forwarded chats and voice messages. Your site downloads a voice message or a forwarded file from api.telegram.org to read it, see "Dealroot AI assistant" below. Telegram's [terms of service](https://telegram.org/tos) and [privacy policy](https://telegram.org/privacy) apply.

= Webhook =

When you enter a webhook URL under Leads → Settings, every new lead and every status change, and the test lead you send from there, are posted to that URL with the lead's contact details, the fields that were sent and how the visitor found your site. The service at that address is chosen by you, for example Make, Zapier or n8n, and its own terms and privacy policy apply.

= Website icons =

Only when you turn on "Website icons" under Leads → Settings → Privacy, or click "Show website icons" below the report of sources, your server loads the icon (favicon.ico, or the icon the home page links to) of each search engine, social network or website in that report from the website itself, for example https://google.com/favicon.ico, and keeps it for a month. The request comes from your server, not from the browser of the person looking at the report, and contains no data about your site, its visitors or its users. The terms and privacy policy of each of these websites apply.

= DB-IP Lite location database =

Only when you turn on "Cities of visitors" under Leads → Settings → Tracking, your server downloads the free IP to City Lite database from DB-IP (https://download.db-ip.com/free/), once right away and then once a month, and keeps it in wp-content/uploads/dealroot. The download is a plain file request that contains no data about your site or its visitors; the city of each visitor is then looked up on your own server. The database is licensed under [Creative Commons Attribution 4.0](https://creativecommons.org/licenses/by/4.0/) by [DB-IP](https://db-ip.com); DB-IP's [privacy policy](https://db-ip.com/privacy.php) applies to the download. Turning the setting off deletes the file.

= Dealroot AI assistant (optional) =

Only when you turn on the AI assistant under Leads → Settings, your site signs up once at Dealroot Cloud (https://cloud.dealroot.net), the service of the makers of this plugin in the European Union: the service fetches a one-time proof from your site's address to confirm it, then gives the site a key to sign its requests. From then on, texts are sent there only to get an answer for a feature you use:

* each new enquiry, with the form name, your site's language and the topics used before, for its summary, topics and kind, and for the confirmation email if you turn it on;
* when you click "Write with AI" or go through new enquiries, the enquiry with the person's name, your name, your site's name and your own quick replies, for a draft of your answer; "Translate" sends the text to translate;
* a question or order under "Ask about your leads" or in Telegram, with the questions before it, your site's name and address, the names of your channels, topics and forms, a few totals such as the enquiries of this month, and for orders the names of your recent leads, so the assistant knows who you mean; the numbers of an answer are counted on your site;
* a chat, text file or email you forward in Telegram to turn it into a lead;
* a voice message you record in the plugin or send in Telegram, as audio, to write it down;
* once a week, the summaries of enquiries about frequent topics and the figures of "Your week in short", for questions people ask and the advice of the week; with Dealroot Pro, also the texts of its own AI features.

Email addresses, phone numbers and fields such as consent boxes are left out by the plugin, and contact details that remain in a text are removed by the service before a language model sees it. The service passes the text to the language model of Mistral AI (Paris, France), which runs in the European Union; when Mistral AI is not available or the monthly allowance of the site is used up, a model on Dealroot's own server answers instead. Voice messages are written down on Dealroot's own server. Dealroot Cloud does not store or log texts, audio or answers, and they are not used for training; Mistral AI processes them as a processor under its [commercial terms](https://legal.mistral.ai/terms/commercial-terms-of-service) and [privacy policy](https://legal.mistral.ai/terms/privacy-policy).

With Dealroot Pro you can instead enter your own API key of OpenAI, Google Gemini, Anthropic Claude or Mistral AI. The key is sent to Dealroot Cloud, checked with the provider once and kept there encrypted, and the texts above then go through Dealroot Cloud to that provider under your own contract with it: [OpenAI terms](https://openai.com/policies/) and [privacy policy](https://openai.com/policies/privacy-policy/), [Google Gemini API terms](https://ai.google.dev/gemini-api/terms) and [Google privacy policy](https://policies.google.com/privacy), [Anthropic commercial terms](https://www.anthropic.com/legal/commercial-terms) and [privacy policy](https://www.anthropic.com/legal/privacy).

Turning the assistant off removes the sign-up. Dealroot Cloud [terms](https://dealroot.net/terms/) and [privacy policy](https://dealroot.net/privacy-policy/).

= MaxMind GeoLite2 City (optional) =

Only when you enter a MaxMind account ID and license key under Leads → Settings → Tracking → Cities of visitors, your server downloads the GeoLite2 City database from MaxMind (https://download.maxmind.com), right away and then once a week, and keeps it in wp-content/uploads/dealroot. The request carries your account ID and license key so MaxMind can check them; it contains no data about your site's visitors, whose cities are looked up on your own server. The database is used under the [GeoLite2 End User License Agreement](https://www.maxmind.com/en/geolite2/eula) of MaxMind; MaxMind's [privacy policy](https://www.maxmind.com/en/privacy-policy) applies to the download. This product includes GeoLite2 data created by MaxMind, available from https://www.maxmind.com. Removing the key or turning off cities deletes the file.

= GeoNames postcode lists =

When "Cities of visitors" is on, your server downloads the free postcode list of a country from GeoNames (https://download.geonames.org/export/zip/): the one of your site's country, and that of another country the first time a lead from there gives a postcode or a town. The lists are replaced every three months and kept in wp-content/uploads/dealroot; they place leads by the postcode or town they gave. The download is a plain file request without data about your site or its visitors. The lists are licensed under [Creative Commons Attribution 4.0](https://creativecommons.org/licenses/by/4.0/) by [GeoNames](https://www.geonames.org). Turning the setting off deletes them.

= Microsoft Clarity =

Dealroot does not add Clarity to your site. If the Clarity tag is already on a page, the tracker marks visits in which a form was sent or a phone, WhatsApp or email link was clicked with the events "dealroot_form_sent" and "dealroot_contact_click" through Clarity's own script, and asks Clarity to keep these recordings, so you can open the recording from the lead. Only these event names are passed on, no form data. Microsoft's [Clarity terms](https://clarity.microsoft.com/terms) and [privacy statement](https://privacy.microsoft.com/privacystatement) apply.

= Map outlines =

The outlines of the countries and the towns on the maps come from [Natural Earth](https://www.naturalearthdata.com/), which is in the public domain, and ship with the plugin. The map loads nothing from other servers.

== Screenshots ==

1. The overview: key figures of the period, what needs your attention and where your leads come from.
2. Leads on the board. Drag a lead to the next stage; marking it as won asks for the amount.
3. All leads with their channel, campaign, status and value.
4. A lead with its stage, the keyword, a quick reply and the deal value.
5. The form scan lists every form of your site, also those built without a form plugin.
6. Settings in sections, with switches.

== Changelog ==

= 0.31.1 =
* Form analytics show only the days counted the new way, from the day of this update: the days before missed visitors without consent and forms sent by script, so they would have shown too few sent forms. The counters of the day of the update start again.

= 0.31.0 =
* Overview: the periods Today and Yesterday, compared with yesterday by the same time and with the day before.
* Overview: "Show the numbers" below the form that people give up lists every form of the week with its starts, sends and every field visitors left it at.
* Form analytics count every visitor, without cookies and without consent: only the form, the label of the field and whether it was sent. The privacy text says so.
* A form sent by script, e.g. the block checkout of WooCommerce, counts as sent when the page sends what was typed or goes to the next page right after its button.
* The board links to the enquiries put into spam.
* A lead shows the keyword of its ad click; add-ons can add more facts at the top of a lead.
* Old links of the overview keep the filters of add-ons, e.g. the person a lead belongs to.

= 0.30.0 =
* New screen Reports, with charts of the chosen period: revenue and ad costs over time, enquiries and new customers, rings of the enquiries and of the revenue by channel, which channel brings customers, when enquiries arrive in the week, how fast you answer, phone or computer, and why deals were lost.
* Above the charts: the last 7 days next to the 7 before, and this month day by day next to last month.
* Hover over a chart to see its numbers; "Show the numbers" opens the same numbers as a table.
* Each channel keeps its colour on every chart, chosen so neighbouring colours stay apart, also for colour-blind readers.
* The PDF report shows the same charts.
* Charts and figures use the currency most of your revenue comes in.
* "Ask about your leads" moved from the overview to a screen of its own, Ask, with room for the whole conversation: it grows with the page while the field stays at the bottom, and ideas what to ask or say are below.
* Topics are what people want to buy or have done. How an order is delivered, picked up or paid, e.g. "Pickup" or "Delivery", is no longer a topic, on every site and in every language; topics read before are cleaned on the update.
* "Phone or computer": the device most enquiries came from is the darkest.
* "The last 7 days" and "Revenue and ad costs": the highest column always fits its chart.
* The month card is called "Won this month" and says that it counts every deal won this month, whenever its enquiry came, while the figures at the top count the deals of the enquiries of the period.
* "Last 7 days", "Last 30 days" and "Last 90 days" are whole days: today and the days before it, the same days as on the charts, compared with as many whole days before.
* Overview: a question mark next to the cost per lead, the cost per customer, the gross profit and the profit on ad spend shows how each is counted, with your numbers.
* Security: every screen, chart and email passes its markup through wp_kses() when it is printed; the PDF report and the remembered list or board view need the nonce of the screen; the public routes of the tracker, Telegram and the sign-up check their permission in their own callback.
* For add-ons: the tracker tells at which field a visitor left a form half done, and the form statistics list the fields where visitors stop most.

= 0.29.0 =
* Reports speak plainer: the attribution switch now reads "How they first came" and "Just before writing", with one line explaining the difference.
* Each column of the overview carries a short explanation on hover, from Visits to ROAS.
* Campaigns: traffic without a campaign is grouped below the campaigns and shown by its channel, so the list no longer mixes both.
* The PDF report explains each number under its tile, notes how enquiries are counted, and leaves out empty city, country, device and browser lists.
* Board cards show the short summary of the enquiry.
* Answers written in WhatsApp or in your email program go into the conversation only once you confirm they were sent; one noted by mistake can be removed.
* "Ask about your leads" is more compact: each row of an answer fits on one line with its bar, and a title that only repeats the question is left out.
* For Pro: the list and the board can show who takes care of each lead and filter by person.
* Campaigns from an ad platform whose links name no campaign show the clicks the platform counted instead of an empty Visits column, with a tip how to add the campaign to the links.
* The groups of the settings menu stand out in yellow and larger type.
* Faster with many leads: the overview of a site with 20,000 enquiries and a year of visits loads in about half the time. Sums of past days are kept until the next day, and new indexes help the lists and the first answer.
* Fewer database queries on each page of the site: the options read there load together with the others.
* The live view asks open pages less often while nobody watches: once a minute when a page lies idle, at most every 20 seconds while it is read. The first sign of a page comes after eight seconds, so a customer clicking through a shop costs no extra requests.
* WooCommerce: the email and Telegram message about a new order go out in the background, so the customer no longer waits for them when placing the order.

= Earlier versions =
See changelog.txt in the plugin folder.
