=== Source Medium Tracker for Contact Form 7 ===
Contributors: asynadak
Tags: contact form 7, tracking, source, medium, utm, campaign, analytics, landing page
Requires at least: 5.0
Tested up to: 7.0
Requires PHP: 7.0
Stable tag: 3.1
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Tracks the source, medium, campaign, content, term, and initial landing page URL of visitors and includes this attribution data in Contact Form 7 submissions.

== Description ==

**Source Medium Tracker for Contact Form 7** allows you to track the complete acquisition journey (`utm_source`, `utm_medium`, `utm_campaign`, `utm_content`, `utm_term`, `landing_page`) of visitors who submit your Contact Form 7 forms. 

Version 3.1 introduces automatic Landing Page URL tracking, custom Contact Form 7 special mail tags, local self-contained script bundling, full campaign tracking, and a modern WordPress admin dashboard.

**Key Features:**

- **Landing Page URL Tracking:** Capture the initial URL where the visitor first landed on your site and automatically append it to admin notification emails.
- **Full UTM Parameter Suite:** Capture `utm_source`, `utm_medium`, `utm_campaign`, `utm_content`, and `utm_term` across visitor sessions.
- **Custom Contact Form 7 Email Tags:** Use custom tags like `[smt-source]`, `[smt-medium]`, `[smt-campaign]`, `[smt-content]`, `[smt-term]`, and `[smt-landing-page]` anywhere in your Contact Form 7 email templates.
- **Modern WordPress Admin UI:** Tabbed navigation, responsive KPI cards, and native WordPress list table styling.
- **Self-Contained & GDPR Compliant:** All charting and JavaScript libraries are bundled locally—no external CDN calls or privacy concerns in the WP Admin area.
- **Detailed Analytics:** View conversion reports broken down by Source, Medium, Campaign, and individual Contact Form.
- **Dashboard Widget:** Quick stats on daily form submissions and interactive trend graphs over time with custom date filtering.
- **Ad Conversion Pixels:** Integrated tracking options for Google Ads, Google Analytics 4 (GA4), and Meta (Facebook) Pixel.

**Benefits:**

- **Optimize Marketing ROI:** Know exactly which campaigns, ads, keywords, landing pages, and channels generate real leads.
- **Full Email Flexibility:** Insert lead source and landing page tags wherever you want in sales notification emails.
- **Zero Configuration Friction:** Automatically handles hidden fields, cookies, and database migration out of the box.

== Installation ==

1. **Upload the Plugin:**
   - Upload the plugin files to the `/wp-content/plugins/source-medium-tracker-for-contact-form-7` directory, or install the plugin through the WordPress plugins screen directly.
2. **Activate the Plugin:**
   - Activate the plugin through the 'Plugins' screen in WordPress.
3. **Configure Settings:**
   - Go to **CF7 Tracker > Settings** in your WordPress admin dashboard to view available custom email tags or configure Google/Meta pixel IDs.
4. **You're All Set:**
   - The plugin automatically tracks visitor sessions, populates hidden form fields, and logs attribution metrics.

== Frequently Asked Questions ==

= How do I use the custom Contact Form 7 email tags? =

Edit any Contact Form 7 form, go to the **Mail** tab, and place any of the following tags inside your **Message Body**:
- `[smt-source]` or `[_smt_source]`
- `[smt-medium]` or `[_smt_medium]`
- `[smt-campaign]` or `[_smt_campaign]`
- `[smt-content]` or `[_smt_content]`
- `[smt-term]` or `[_smt_term]`
- `[smt-landing-page]` or `[_smt_landing_page]`

If you omit these tags, the plugin will automatically append a summary to the bottom of admin notification emails as a fallback.

= Is this plugin compatible with all versions of Contact Form 7? =

The plugin is compatible with Contact Form 7 version 5.0 and above.

= Does this plugin use external CDNs for admin scripts? =

No. As of version 3.0, all analytics scripts (Chart.js, Moment.js) are bundled locally within the plugin, ensuring 100% GDPR compliance and offline compatibility.

= How can I view form submission reports? =

Navigate to **CF7 Tracker** in your WordPress admin menu. You can switch between the **Overview** graph, **Sources & Mediums** report, and **Form Analytics** tabs.


== Changelog ==

= 3.1 =
* NEW: Landing Page URL Tracking: Automatically tracks the initial landing page URL where visitors entered the website.
* NEW: Automatically includes User Landing Page in Contact Form 7 admin notification emails.
* NEW: Added [smt-landing-page] and [_smt_landing_page] special mail tags for CF7 email templates.
* NEW: Database schema upgraded to v1.2.

= 3.0 =
* NEW: Full UTM Parameter Suite: Track utm_source, utm_medium, utm_campaign, utm_content, and utm_term across visitor sessions.
* NEW: Contact Form 7 Custom Special Mail Tags: Insert custom tags ([smt-source], [smt-medium], [smt-campaign], [smt-content], [smt-term]) directly into CF7 email templates.
* NEW: Modern Tabbed Admin UI: Redesigned admin interface featuring WP-standard list tables, KPI summary cards with trend badges, and tabbed navigation.
* NEW: Local Asset Bundling: Self-contained Chart.js and Moment.js vendor scripts bundled locally for offline compliance and zero external CDN dependency.
* NEW: Mail Tags Usage Reference card added to settings page.
* FIX: Resolved database uninstall script SQL table drop syntax issue.
* FIX: Removed duplicate dashboard chart canvas tags.

= 2.5 =
* In the dashboard home widget added functionality to display count of submitted forms for the last 30 days.
* In the dashboard home widget added functionality to compare with previous 30 days.

= 2.4.5 =
* Fixed a bug where the source/medium was also included in the client's email apart from the admin's.
* Tested with latest WordPress version (6.8.2).

= 2.4.1 =
* Improvements: Minor improvement to categorize better traffic from email mobile apps like Gmail.
* Various code improvements

= 2.4 =
* NEW: Added multi-form support and reporting. Users can now track and analyze submissions from multiple Contact Form 7 forms individually.
* Improvements: Enhanced user interface and data visualization.

= 2.3 =
* NEW: Added conversion tracking for Google Ads, Google Analytics and Facebook Pixel.

= 2.0 =
* NEW: Stores submission data in a custom database table.

= 1.0 =
* Initial release.

== Upgrade Notice ==

= 3.1 =
Version 3.1 adds automatic Landing Page URL tracking and mail tags ([smt-landing-page]). Update now to track exact entry URLs for all leads!

== License ==

This plugin is free software; you can redistribute it and/or modify it under the terms of the [GNU General Public License version 2](https://www.gnu.org/licenses/gpl-2.0.html).
