=== SEODAY-WP-GA4-SST ===
Contributors: seodaygmbh
Donate link: https://seo-day.de
Tags: google analytics, ga4, server-side tracking, measurement protocol, analytics
Requires at least: 5.0
Tested up to: 6.8
Requires PHP: 7.4
Stable tag: 2.2.1
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Server-side Google Analytics 4 tracking for WordPress using Measurement Protocol API.

== Description ==

SEODAY-WP-GA4-SST enables server-side tracking for Google Analytics 4 (GA4) in your WordPress site. Unlike traditional client-side tracking, this plugin sends events directly from your server to GA4 using the Measurement Protocol API.

= Key Features =

* **Server-Side Tracking**: All GA4 events are sent from your server, not from the visitor's browser
* **Privacy-Friendly**: No client-side tracking scripts required
* **Automatic Events**: Tracks page views, session starts, first visits, and user engagement
* **Detailed Logging**: View all GA4 API calls with request/response details
* **Easy Configuration**: Simple setup with Measurement ID and API Secret
* **Statistics Dashboard**: Monitor tracking activity with comprehensive stats
* **Developer-Friendly**: Includes API for custom event tracking

= Why Server-Side Tracking? =

Server-side tracking offers several advantages:
* **Ad Blocker Resistant**: Events are sent from your server, bypassing ad blockers
* **Data Accuracy**: More reliable than client-side tracking
* **Better Performance**: No additional JavaScript loaded in the browser
* **Enhanced Privacy**: Full control over what data is sent to GA4

= Events Tracked =

* **page_view**: Automatic tracking of all page views
* **session_start**: First page view in a session
* **first_visit**: First time a user visits your site
* **user_engagement**: User interaction tracking

= Requirements =

* WordPress 5.0 or higher
* PHP 7.4 or higher
* Google Analytics 4 property with Measurement Protocol enabled
* GA4 Measurement ID and API Secret

== Installation ==

1. Upload the plugin files to the `/wp-content/plugins/seoday-wp-ga4-sst-plugin/` directory, or install the plugin through the WordPress plugins screen directly.
2. Activate the plugin through the 'Plugins' screen in WordPress.
3. Go to Settings → GA4-SST to configure the plugin.
4. Enter your GA4 Measurement ID (format: G-XXXXXXXXXX).
5. Enter your GA4 API Secret (can be created in GA4 Admin → Data Streams → Measurement Protocol API secrets).
6. Enable the "Activate" checkbox to start tracking.

== Frequently Asked Questions ==

= Where do I find my Measurement ID? =

1. Log in to your Google Analytics 4 account
2. Go to Admin → Data Streams
3. Select your web data stream
4. Your Measurement ID is displayed at the top (format: G-XXXXXXXXXX)

= How do I create an API Secret? =

1. Log in to your Google Analytics 4 account
2. Go to Admin → Data Streams
3. Select your web data stream
4. Click on "Measurement Protocol API secrets"
5. Click "Create" to generate a new API secret
6. Copy the secret value and paste it in the plugin settings

= Why don't I see events in GA4 immediately? =

* Check the GA4 Realtime report first (events appear within 10-30 seconds)
* Standard reports can take 24-48 hours to update
* Verify your Measurement ID and API Secret are correct
* Check the GA4-Logs page in the plugin to see if events are being sent successfully

= Can I track custom events? =

Yes! Developers can use the plugin's API to send custom events:

`
if (class_exists('WP_GA4_SST_Tracker')) {
    $tracker = new WP_GA4_SST_Tracker();
    $tracker->track_event('custom_event_name', array(
        'parameter1' => 'value1',
        'parameter2' => 'value2'
    ));
}
`

= How long are logs stored? =

Logs are automatically deleted after 30 days to keep your database clean.

= Does this work with caching plugins? =

Yes, server-side tracking works independently of caching plugins since events are sent from the server, not the browser.

== Screenshots ==

1. Settings page - Configure your GA4 Measurement ID and API Secret
2. Logs page - View all GA4 API calls with detailed request/response data
3. Statistics - Monitor your tracking activity

== Changelog ==

= 2.2.1 =
* Fixed: Text Domain changed to 'seoday-wp-ga4-sst' to match plugin slug
* Fixed: Removed deprecated load_plugin_textdomain() function (not needed since WP 4.6)
* Fixed: Stable tag mismatch in readme.txt

= 2.2.0 =
* Added: Delete All Logs button in GA4-Logs page
* Added: Confirmation dialog before deleting logs
* Improved: Better UI for logs management

= 2.1.0 =
* Improved: All events now sent in a single GA4 call per page view
* Optimized: Reduced API calls to GA4

= 2.0.0 =
* Added: Copy button for request/response data in logs
* Added: Automatic validation for activate checkbox
* Improved: User-Agent header now sent correctly to GA4
* Improved: engagement_time_msec parameter added to page_view events
* Fixed: Menu structure corrected

= 1.9.0 =
* Added: User-Agent header support for GA4 calls
* Added: engagement_time_msec parameter for better GA4 reporting
* Fixed: Removed user_agent from event params (now sent as HTTP header)

= 1.0.0 =
* Initial release
* Server-side page view tracking
* Session and first visit tracking
* User engagement tracking
* Comprehensive logging system
* Statistics dashboard

== Upgrade Notice ==

= 2.2.1 =
Important WordPress.org compliance update. Text domain corrected to match plugin slug for proper translations. No functional changes.

= 2.2.0 =
Added Delete All Logs button for better log management.

= 2.1.0 =
Performance improvement: All events now sent in a single GA4 call per page view.

= 2.0.0 =
This version includes important GA4 tracking improvements. The User-Agent header is now sent correctly, and engagement_time_msec is included in all page_view events for better reporting accuracy.

== Developer Documentation ==

= Custom Event Tracking =

Track custom events using the WP_GA4_SST_Tracker class:

`
// Example: Track a form submission
add_action('wpcf7_mail_sent', function($contact_form) {
    if (class_exists('WP_GA4_SST_Tracker')) {
        $tracker = new WP_GA4_SST_Tracker();
        $tracker->track_event('form_submission', array(
            'form_id' => $contact_form->id(),
            'form_title' => $contact_form->title()
        ));
    }
});
`

= Available Hooks =

The plugin provides several hooks for customization:

* `wp_ga4_sst_before_send`: Fired before sending an event to GA4
* `wp_ga4_sst_after_send`: Fired after sending an event to GA4

= Database Schema =

The plugin creates a custom table `wp_ga4_sst_calls` with the following fields:
* `id`: Auto-increment primary key
* `timestamp`: DateTime of the call
* `day`: Date (for filtering)
* `domain`: Domain name
* `response_code`: HTTP response code
* `request`: JSON request payload
* `response`: JSON response data

== Privacy Policy ==

This plugin sends data to Google Analytics 4 servers. The following data is transmitted:

* Client ID (anonymous identifier stored in a cookie)
* Page URL and title
* User role (WordPress role if logged in)
* User-Agent information
* Language preference
* Referrer URL

No personally identifiable information (PII) is sent unless you explicitly configure it through custom events.

The plugin stores technical logs of GA4 API calls in your WordPress database for debugging purposes. These logs are automatically deleted after 30 days.

== Support ==

For support, please visit:
* Plugin Website: https://wp-ga4-sst.seo-day.de
* Email: info@seo-day.de

== Credits ==

Developed by SEO-DAY GmbH
* Website: https://seo-day.de
* Developer: Fabian Rossbacher
* Address: Adolf-Kaschny-Straße 19, 51373 Leverkusen, Germany

