=== Sampi Metrics ===
Contributors: sampiai
Tags: analytics, statistics, post views, page views, metrics
Requires at least: 6.0
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 1.0.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Counts post views for sites connected to Sampi, including posts published directly in WordPress. Works behind page cache and CDN.

== Description ==

[Sampi](https://sampi.ai) is a content platform for newsrooms and brands. Posts that Sampi publishes to WordPress already report their views back to Sampi. Sampi Metrics extends that to every post on the site, including the ones written directly in WordPress, so Sampi reports show views for all of your content.

How it works:

* On each single post page, the plugin adds a 1x1 image to the page footer. Loading that image adds one view to the post counter in your Sampi account.
* Because the count happens in the visitor browser, it keeps working when the site is served from a full page cache or a CDN.
* The image is printed by the theme footer and is never saved into the post content. Deactivating the plugin removes it from every page.
* Posts published by Sampi already carry the counter, so the plugin skips them and a view is never counted twice.
* No cookies, no JavaScript, no personal data in the request.

View counting stays off until a site administrator turns it on, either in Settings > Sampi Metrics or from the Sampi integration screen.

== External services ==

This plugin connects to the Sampi view counter, a service provided by Sampi, to count post views. It is required to show views of your posts inside your Sampi account.

What is sent and when: only after an administrator turns view counting on, every time a visitor opens a single post page, the visitor browser requests a 1x1 image from `https://gc-api-evnvui3szq-rj.sampi.ai/_public/pixel/`. The request URL contains only a key that identifies the post (a hash of the site host and the post ID). As with any web request, the Sampi server receives the visitor IP address and browser user agent. Sampi uses the user agent only to discard bots and does not store the IP address with the count. No cookies are set and no page content is sent.

The plugin also offers a REST route (`/wp-json/sampi/v1/status`) that Sampi calls with the credentials you gave it, to check that the plugin is active.

Sampi terms of use: https://app.sampi.ai/termos-de-uso
Sampi privacy policy: https://app.sampi.ai/politica-de-privacidade

== Installation ==

1. In your WordPress admin, go to Plugins > Add New, search for "Sampi Metrics", then install and activate it. You can also upload the plugin folder to `/wp-content/plugins/`.
2. Go to Settings > Sampi Metrics, check "Send post views to Sampi" and save.
3. In Sampi, connect this site under Integrations > WordPress, if you have not done it yet.

If your site is already connected to Sampi with an administrator account, Sampi can install and turn the plugin on for you from its integration screen.

== Frequently Asked Questions ==

= Do I need a Sampi account? =

Yes. The views are counted in your Sampi account and shown in Sampi reports. Without a Sampi account the plugin has nothing to report to.

= Does it work with caching plugins and CDNs? =

Yes. The counter is an image loaded by the visitor browser, so cached pages still count every view.

= Does it change my posts? =

No. The image is added to the page footer when the post is displayed and is never saved in the post content.

= Are bots counted? =

Requests from known bots, crawlers and link preview tools are discarded by the Sampi server based on the user agent.

= Does it set cookies or collect personal data? =

No cookies are set and the request carries only the post key. The Sampi server receives the visitor IP address and user agent, like any web server does, and uses the user agent only to discard bots. The plugin adds a suggested paragraph to Settings > Privacy that you can copy to your privacy policy.

= How do I stop counting? =

Uncheck the option in Settings > Sampi Metrics, or deactivate the plugin. Deleting the plugin also removes its setting.

== Changelog ==

= 1.0.0 =
* First public release: view counter for every single post, opt-in setting, status route for the Sampi integration and suggested privacy policy text.

== Upgrade Notice ==

= 1.0.0 =
First public release.
