=== SteClick Counter ===
Contributors: kasuga16
Donate link: https://www.paypal.me/kasuga16
Tags: click tracking, download tracking, pdf tracking, link counter, analytics
Requires at least: 6.0
Tested up to: 6.9
Requires PHP: 7.4
Stable tag: 1.0.2
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Lightweight click tracking for WordPress. Track any link or button by simply adding a prefix to your URLs.

== Description ==

SteClick Counter is a lightweight WordPress plugin that lets you track link clicks by doing just one thing:  
**adding a simple prefix to your existing URLs.**

No complex setup. No JavaScript. No external analytics services.

To start tracking clicks, simply add the prefix **`/?tag=XXX&to=`** before the URL you want to track.  
The plugin logs the click and immediately redirects the visitor to the destination.

This makes SteClick Counter ideal for tracking:
- Download buttons
- PDF links
- Embedded content
- External links and call-to-action buttons

**Key Benefits:**
* **Simple Prefix System:** No configuration required. Just add **`/?tag=XXX&to=`** to any link and start tracking instantly.
* **Lightweight & Fast:** No JavaScript and no performance impact on your site.
* **Database Lean:** Uses the file system for logging instead of creating database tables.
* **Privacy-First:** No cookies, no tracking scripts, and no third-party services.

== How It Works ==

To track a link, prepend the **`/?tag=XXX&to=`** prefix to the original URL.

**Original URL:**
*https://example.com/document.pdf*

**Tracked URL:**
*/?tag=doc-01&to=https://example.com/document.pdf*

---

### Tracking a download link (HTML example)

You can also track download buttons or links by modifying the `href` attribute.

**Original HTML:**
*&lt;a href="https://example.com/wp-content/uploads/sample.zip"&gt;Download ZIP file&lt;/a&gt;*

**Tracked HTML:**
*&lt;a href="/?tag=zip01&to=https://example.com/wp-content/uploads/sample.zip"&gt;Download ZIP file&lt;/a&gt;*

When a visitor clicks a tracked link, SteClick Counter records:
- The timestamp
- Your custom tag
- The destination URL
- The referrer (source page)

You can view all click statistics in **Settings → SteClick Counter**.

== Installation ==

- Upload via WordPress Dashboard:
 1. In your WordPress dashboard, go to 'Plugins' → 'Add New'.
 2. Search for "steclick counter" and click 'Install Now'.
 3. Click 'Activate' once the installation is complete.
 4. Start tracking by adding the **`/?tag=XXX&to=`** prefix to your links.
 5. View click counts in **Settings → SteClick Counter**.

- Manual Installation via FTP:
 1. Download the plugin's zip file and extract it.
 2. Connect to your server via FTP and navigate to the "wp-content/plugins/" directory.
 3. Upload the extracted "steclick-counter" folder to this directory.
 4. Go to 'Plugins' in your WordPress dashboard and activate the plugin.
 5. Start tracking by adding the **`/?tag=XXX&to=`** prefix to your links.
 6. View click counts in **Settings → SteClick Counter**.

== Screenshots ==

1. Admin dashboard showing click statistics grouped by tag.

== Changelog ==

= 1.0.2 =
* Improved: Referrer is now captured when links are opened in a new tab (`target="_blank"`).

= 1.0.1 =
* Added: Inline script on the frontend to automatically rewrite relative `/?tag=XXX&to=` hrefs to absolute URLs based on the site's home URL.
* Fixed: `steclick_enqueue_url_fixer()` now returns early on admin pages.

= 1.0.0 =
* Initial release.