=== Sonar Analytics ===
Contributors: fl1digital
Tags: analytics, statistics, privacy, visitors, ai
Requires at least: 5.6
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 2.2.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Privacy-friendly website analytics with AI insights. Paste your Site Key and Sonar starts tracking every page.

== Description ==

Sonar is website analytics that explains itself. See your visitors, top pages, traffic sources and conversions, and ask questions about your data in plain English.

This plugin connects your WordPress site to your Sonar account. Paste your Site Key once and the Sonar tracking script is added to every page of your site. No theme editing needed.

* **Two-minute setup:** paste your Site Key and save.
* **Lightweight:** the tracking script loads asynchronously, so it doesn't slow your pages down.
* **Leave out your own visits:** logged-in administrators and editors aren't tracked (you can change this).
* **Works with agencies:** if your agency gave you their own analytics address, enter it under Advanced.

You need a Sonar account to use this plugin. The Starter plan is free.

== External services ==

This plugin connects your site to **Sonar**, the analytics service you sign up for, to record visits to your website.

* **What is loaded:** each page of your site loads the Sonar tracking script (`tracker.js`) from your Sonar address (by default https://sonar-app.co.uk, or the address set under Advanced).
* **What is sent, and when:** each time a visitor views a page, the script sends the page address and title, the referring site, any UTM campaign tags, screen size, browser language and time zone, and the browser's user agent. Sonar's server also sees the visitor's IP address, which it uses to estimate country and city. No cookies are set by the script.
* **Interactions (optional, off by default):** if you add an Interactions key and turn them on, the plugin also sends Gravity Forms enquiries and WooCommerce basket, checkout and order events to Sonar from your server. Each carries the visitor's IP address and browser, the page view id the tracker gave the page, and for shop events the product names, quantities and values. Customer names, addresses and emails are never sent from WooCommerce; Gravity Forms field values are only sent if you turn that on for a form.
* **Who receives it:** Sonar, to show these visits in your Sonar dashboard.

Nothing is sent until you add a Site Key. Sonar terms of service: https://sonar-app.co.uk/terms. Privacy policy: https://sonar-app.co.uk/privacy.

== Installation ==

1. In your WordPress admin, go to **Plugins → Add New**, search for **Sonar Analytics**, then click **Install Now** and **Activate**.
2. In Sonar, open your site's **Site settings** and copy the **Site Key** from the Tracking code section.
3. In WordPress, go to **Settings → Sonar Analytics**, paste the Site Key and click **Save settings**.
4. Visit your site in a private window, then check your Sonar dashboard. Your visit appears within a minute.

== Frequently Asked Questions ==

= Where do I find my Site Key? =

In Sonar, open the site, go to **Site settings** and look under **Tracking code**. It's also shown when you first add a site.

= Will it slow down my site? =

No. The script loads asynchronously and doesn't block your page from rendering.

= Why can't I see my own visits? =

By default, logged-in administrators and editors aren't tracked, so your own browsing doesn't skew your numbers. Untick "Don't track logged-in administrators and editors" to include them, or check in a private window.

= I use a caching plugin. Do I need to do anything? =

Clear your cache after saving your Site Key so cached pages include the script.

= My agency set up analytics for me. What address do I use? =

If your agency gave you their own address for your dashboard, enter it under **Advanced → Sonar address**. Otherwise leave it blank.

== Changelog ==

= 2.2.0 =
* WooCommerce: send products added to the basket, checkouts started and orders to Sonar as interactions, with their value, linked to the visit (Settings → Sonar Analytics → Interactions).
* Orders are sent once, when paid or awaiting a manual payment. Failed payments aren't counted. Works with the block-based checkout and HPOS order storage.
* Interactions are sent through Action Scheduler when it's available, so a slow connection to Sonar never holds up a checkout.

= 2.1.1 =
* Gravity Forms: reliably sends the Sonar page view id with AJAX forms, so enquiries link to the exact visit.

= 2.1.0 =
* Gravity Forms: send form enquiries to Sonar as interactions, linked to the visit they came from (Settings → Sonar Analytics → Interactions).
* Only the form name and entry number are sent unless a form's "Send field values to Sonar" setting is on. Passwords and card numbers are never sent.

= 2.0.0 =
* Renamed to Sonar Analytics.
* Fixed the tracking script address (now /tracker.js).
* Loads the script the WordPress way (wp_enqueue_script, async).
* Option to leave out logged-in administrators and editors (on by default).
* Settings link on the Plugins page, Site Key validation, and clean removal on uninstall.
* Keeps your Site Key when upgrading from FL1 Website Analytics.

== Upgrade Notice ==

= 2.2.0 =
Adds WooCommerce basket, checkout and order events as Sonar interactions. Nothing is sent until you turn it on.

= 2.1.0 =
Adds Gravity Forms enquiries as Sonar interactions. Nothing is sent until you add an Interactions key and turn it on.

= 2.0.0 =
Renamed to Sonar Analytics and fixes the tracking script address. Your Site Key is kept.
