=== SourceTag – Lead Source Tracking for Forms ===
Contributors: sourcetagio
Tags: attribution, utm, tracking, lead source, contact form
Requires at least: 5.8
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 1.0.6
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Captures UTM parameters, click IDs, referrer data, and landing pages in your contact form submissions. First-touch and last-touch attribution.

== Description ==

SourceTag populates hidden fields in your contact forms with marketing attribution data. When a lead submits a form, you see which channel, campaign, and keyword brought them in.

**What gets captured:**

* Channel (Paid Search, Organic Social, Email, etc.)
* UTM parameters (source, medium, campaign, term, content)
* Click IDs (gclid, fbclid, msclkid, gbraid, wbraid)
* Landing page and referrer
* Visit count and days to conversion
* Device type

**Form builders:**

Works with Contact Form 7, Gravity Forms, WPForms, Elementor Forms, Formidable Forms, HubSpot Forms, and any HTML form that supports hidden fields.

**Why use the plugin instead of just adding the script tag?**

The plugin sets cookies via PHP (HTTP headers) instead of JavaScript. Safari, Brave, and other privacy-focused browsers cap JavaScript cookies at 7 days. Server-set cookies last up to 400 days.

== External services ==

This plugin connects to SourceTag, a hosted lead attribution service. It does not work without a SourceTag account.

It loads your SourceTag tracking script from `cdn.sourcetag.io` on every front-end page. On form submit, the script sends your site ID and a timestamp to `cdn.sourcetag.io`. No form contents or personal data are sent to SourceTag.

SourceTag terms: https://sourcetag.io/legal/terms
SourceTag privacy policy: https://sourcetag.io/legal/privacy

The `_sourcetag` cookie is set on your visitors' browsers. Make sure your privacy policy and cookie notice cover it where your visitors' jurisdiction requires consent.

== Installation ==

1. In WordPress, go to Plugins > Add New Plugin and search for SourceTag.
2. Click Install Now, then Activate.
3. Go to Settings > SourceTag and paste your Script URL from the [SourceTag dashboard](https://app.sourcetag.io).
4. Add hidden fields to your forms. The [SourceTag docs](https://sourcetag.io/docs) cover each form builder.

== Frequently Asked Questions ==

= Is SourceTag free? =

SourceTag is a paid service with a 14-day free trial, no credit card needed. The plugin is free, but it needs a SourceTag account to work. See [pricing](https://sourcetag.io/pricing).

= Where do I get my script URL? =

Sign up at [sourcetag.io](https://sourcetag.io), add your site, and copy the script URL from the Install Script section on your site's page.

= Does this create hidden fields in my forms? =

No. You add hidden fields to your forms yourself. SourceTag detects them and fills in the values when a visitor submits. The docs cover how to do this for each form builder.

= What about Safari and Brave? =

JavaScript cookies in these browsers expire after 7 days. The plugin's server-side cookie option (on by default) sets the cookie via PHP instead, which these browsers allow for up to 400 days.

= Do I need a consent banner? =

The plugin and script set one first-party cookie, `_sourcetag`, on your domain. Whether you need consent for it depends on where your visitors are. If you already gate analytics cookies behind a consent tool, load the SourceTag script the same way.

== Screenshots ==

1. Settings > SourceTag: paste your Script URL and turn on 400-day server-side cookies.
2. A form entry with the lead's first and last click channel, campaign, keyword, landing page and click ID filled in.

== Changelog ==

= 1.0.6 =
* First release on WordPress.org
