# Markopolo AI Tracker

Track Wordpress events and send them to Markopolo AI analytics platform.

Tracking is off by default. Front-end tracking starts only after an admin explicitly enables tracking in plugin settings and configures a valid Tag ID.

## Events Tracked

- page_view
- click
- form_interaction (change, submit)
- Search

## What It Captures

- Email, phone, and name from supported form fields
- Click metadata such as element tag, id, class, and text
- Search terms from search forms and query parameters
- Persistent `muid` and `sessionId` values stored in the browser

## External Services

This plugin relies on Markopolo AI services for analytics and attribution.

### Event endpoint

- Endpoint: `https://mtag.markopolo.ai/mark`
- Purpose: Receives browser-side analytics events.
- When sent: During tracked front-end events only after explicit admin opt-in and when a valid Tag ID is configured.
- Data may include: tag ID, page metadata, referrer, browser/device details, session/visitor IDs, attribution cookies, click metadata, and form/search values.

### Settings webhook endpoint

- Endpoint: `https://api-alpha.markopolo.ai/v1/integrations/wordpress/webhook`
- Purpose: Receives settings lifecycle webhook events.
- When sent: Only after explicit admin opt-in. Sent on Tag ID set/update/remove and, on uninstall, only when tracking is enabled and a Tag ID is configured.
- Data sent: event name, tag ID, previous tag ID (when applicable), plugin name, site URL, and timestamp.

### Terms and Privacy

- Terms and legal information: https://markopolo.ai/legal
- Privacy policy: https://markopolo.ai/legal

## Installation

1. Build the plugin package:

```bash
./build.sh
```

2. In WordPress admin, go to `Plugins -> Add New -> Upload Plugin`
3. Upload `markopolo-tracker-1.0.1.zip`
4. Activate Markopolo AI
5. Go to `Settings -> Markopolo AI`
6. Enable tracking
7. Set `tag_id` and save

In this plugin, enabling tracking is the explicit admin opt-in. Front-end tracking requires both tracking enabled and a valid `tag_id`.

The plugin uses internal endpoints for browser tracking and settings webhooks. Site admins manage both the explicit tracking toggle and `tag_id`.

## Notes

- The plugin intentionally avoids WooCommerce conversion events like AddToCart, BeginCheckout, and Purchase.
