=== Universal WP Lead Tracking ===
Contributors: inboundhorizons
Tags: lead, tracking, email, contact, form
Requires at least: 4.5
Requires PHP: 7.4
License: MIT
Tested up to: 7.1
Stable tag: 1.0.15

Adds lead tracking information to e-mails coming from Contact Form 7, Gravity Forms, Ninja Forms, or Elementor PRO form submissions. 

== Description ==

Universal WP Lead Tracking gives you important information about users from contact form submissions on your Wordpress site and allows you to instantly set up Google Analytics events to send conversion data when someone submits a form on your website.

When you receive an e-mail from a contact form on your website, you will instantly see data on a user's landing page on your site, the page that they filled out the contact form on, the referring source that sent them to your website, their location IP (country-level) and browser/platform used. 

This information is added by simply putting the `[tracking-info]` shortcode in the email being sent to you when a user submits a form on your website. Just paste the `[tracking-info]` shortcode in your e-mail template, and every time you receive a lead from your website, you will be able to see information from the user that submitted the form. 

= The Specific Information This Plugin Provides =

The tracking info specifically includes the Form Page URL, Original Referrer, Landing Page, Lead Source, Campaign, Ad Click ID, User IP, and Browser. What do these specific items mean?

* Form Page URL: This is the page on your website where the user filled out your form.
* Original Referrer: This is where the user came to your website from such as Google or Facebook. If there was no referring website, the source name is shown instead, such as a newsletter or "direct".
* Landing Page: This is the page on your website that the user first came to from an outside source.
* Lead Source: This is how the user first found your website, such as Google Ads, organic search, social media, email, another website, or a direct visit.
* Campaign: This is the campaign name (the utm_campaign value) from the link the user first clicked, when there is one.
* Ad Click ID: This is the ad click ID (such as a Google Ads gclid) from the user's first visit, when there is one.
* Most Recent Visit: This is only included when the user came back through a different source or page before sending the form.
* Most Recent Ad Click ID: This is only included when the user's most recent visit was an ad click with a different click ID than their first visit. Use it to credit the ad that led to the form.
* User IP: This is the IP address of the user that sent a form submission and includes a country location.
* Browser: This tells you what browser a user was on when they sent a form submission.

= Accurate Referrer And Landing Page Tracking =

The referrer and landing page are captured in the visitor's browser the moment they arrive, so they stay accurate even on sites that use page caching. The information is remembered for 90 days, and the visitor's first visit is never overwritten, so a lead who comes back days later is still credited to the source that first brought them to your website.

The plugin recognizes Google Ads (gclid, gbraid, wbraid), Microsoft Ads (msclkid), Facebook (fbclid), TikTok (ttclid), and LinkedIn (li_fat_id) click IDs, as well as UTM parameters, search engines, social networks, and other referring websites.

= This Tracking Code Works With Most Major Form Plugins =

This shortcode tracking method will work with forms on Contact Form 7, Gravity Forms, Ninja Forms, or Elementor PRO. Because it is shortcode based, you can just drop in the code to the e-mail submission template on any of these major form plugins. 

If you are sending your website e-mail submissions via an HTML based output on one of these plugins, we have that covered too. Just add html="true" to your shortcode like so: `[tracking-info html="true"]`

= This Plugin Sends Form Events To Google Analytics =

As an added feature, you can track any form submission on your website as a Google Analytics event if you have Google Analytics set up on your website. 

This happens automatically when you check the box for the Analytics event you want on the plugin settings section. We currently support ga{} events for Universal Analytics and gtag{} events for Google Analytics 4. 

This will show up in your Google Analytics view as an action called "submit" with an event category called "Contact Form" that you can then set as a lead source in your conversion preferences in Google Analytics

For more plugins, help, or information about this plugin please visit [www.inboundhorizons.com](https://www.inboundhorizons.com/product/wp-universal-lead-tracking-free-wordpress-plugin/ "Inbound Horizons - Universal WP Lead Tracking").

== Frequently Asked Questions ==

= Does this plugin set a cookie? =

Yes. The plugin sets one first-party cookie named `uwplt_attr` in the visitor's browser. It lasts 90 days and holds the landing page, referring website, lead source, campaign, and ad click ID for the visitor's first visit and most recent visit. Nothing in it identifies the visitor personally. The cookie is only read by your own website when a form is submitted, and nothing is sent to Inbound Horizons or any other third party. Depending on where your visitors are and your own policies, you may want to mention this cookie in your privacy policy or cookie consent tool.

= Does this plugin store visitor information in my database? =

No. Attribution is kept only in the visitor's cookie. Websites upgraded from earlier versions may still have a small table named track_sessions from the old method. It is no longer used or written to.

= Why is the Ad Click ID or Lead Source missing for some leads? =

Some browsers, extensions, and privacy settings remove tracking parameters such as gclid from the address before the page loads, and some visitors block cookies. When that happens the plugin can only report what it can see, such as the referring website or a direct visit.

== Screenshots ==

1. This is the view of the plugin admin panel options you will see in Wordpress
2. This is an example of where you will enter the tracking shortcode on a web form. This is an example from a Contact Form 7 mail form sent to the Wordpress site administrator after a user submits a form on the site.
3. This is an example of the tracking information you will receive at the bottom of a response email when a user submits a form on your site.

== Changelog ==

= 1.0.15 - 2026-09-30 =
* FIX: The Original Referrer and Landing Page are now captured in the visitor's browser when they arrive, so they are accurate on sites that use page caching. Previously the site itself could be recorded as the referrer.
* FIX: Attribution is no longer lost when a cached page's security token expires. The tracking script no longer uses a token, AJAX, or the database.
* UPDATE: Attribution is now remembered for 90 days (previously 6 hours), so a visitor who returns days later is still credited to the source that first brought them. The first visit is never overwritten.
* ADD: The [tracking-info] shortcode now includes Lead Source, Campaign, and Ad Click ID lines. A Most Recent Visit line is included only when the visitor came back through a different source or page, along with a Most Recent Ad Click ID line when that visit was an ad click.
* ADD: Recognizes Google Ads (gclid, gbraid, wbraid), Microsoft Ads (msclkid), Facebook (fbclid), TikTok (ttclid), and LinkedIn (li_fat_id) click IDs, plus UTM parameters.
* UPDATE: Updated the Example Tracking Info on the settings page to show the new fields.
* UPDATE: The tracking script is excluded from common caching and optimization plugins so it always runs.
* UPDATE: Click IDs of up to 255 characters and landing page URLs of up to 500 characters are now stored, so long Google Ads click IDs are never cut off.
* UPDATE: Minimum required PHP version is now 7.4.
* UPDATE: Minimum required WordPress version is now 4.5.
* FIX: The Google Analytics event script now has an explicit version number.
* FIX: The Google Analytics event script no longer causes a JavaScript error on pages that do not load jQuery.
* FIX: A missing or unreadable IP 2 Location database file can no longer cause a fatal error on PHP 8. The user's country is left blank instead.
* UPDATE: Confirmed compatibility with WordPress v7.1.2.
* UPDATE: Updated IP 2 Location database to latest release of September 2026.

= 1.0.9 - 2025-07-14 =
* FIX: Added code to set tracking info by JS if not set via HTTP. Required for cached pages.

= 1.0.8 - 2025-07-08 =
* FIX: Landing URLs could sometimes be set to /wp-json/ or /wp-admin/admin-ajax.php which is incorrect. Added a check to exclude ADMIN pages, AJAX requests, REST requests, and WP-CRON requests.
* UPDATE: Refactored some code and make it more robust.
* UPDATE: Updated IP 2 Location database to latest release of July 2025.

= 1.0.7 - 2025-05-20 =
* UPDATE: Added a field to set a custom Google Analytics event (default event is "submit").
* UPDATE: Confirmed compatibility with WordPress v6.8.
* UPDATE: Updated IP 2 Location database to latest release of May 2025.

= 1.0.5 - 2024-04-03 =
* UPDATE: Confirmed compatibility with WordPress v6.5.
* UPDATE: Updated IP 2 Location database to latest release of April 2024.

= 1.0.4 - 2024-04-01 =
* UPDATE: Bumped version.

= 1.0.3.4 - 2024-03-27 =
* FIX: Fixed small bugs with "if" checks.
* UPDATE: Updated IP2Location database.

= 1.0.3.2 - 2023-09-29 =
* FIX: Fixed small bug causing error in background.
* UPDATE: Updated IP2Location database.

= 1.0.3.1 - 2023-02-01 =
* TWEAK: Cleaned up some code and clarified wording on settings page.
* ADD: Added IP lookup functionality to find country based on IP address. IPv6 requires the GNU Multiple Precision (GMP) extension to be installed.

= 1.0.3 - 2023-01-25 =
* TWEAK: Changed some wording on admin page and edited readme.txt

= 1.0.2 - 2022-11-04 =
* TWEAK: Tested with WordPress v6.1

= 1.0.1.3 - 2022-10-28 =
* FIX: Escaped HTML and Scripts

= 1.0.1.2 - 2022-10-27 =
* TWEAK: Updated readme