# How it Works

1. **First Scan:** Once a MatchAgent is loaded onto your website, it will scan and use the website's full context for optimizing content.
2. **UTM Rule Check:** The script reads UTM parameters in the page URL and checks them against the rules configured in your MatchAgent (e.g., `utm_source equals google`). If a match is found, personalization fires. If not, the page displays normally.
3. **Content Swap:** Only the elements you've mapped in the MatchAgent are updated — H1s, subheads, CTAs, badges, or sections. The rest of the page remains untouched.
4. **Caching:** After the first time a unique set of UTM keys is run through the system, those hyper-personalized variants will be cached for instantaneous retrieval on subsequent page loads.
5. **Editable Fields:** These cached AI-optimized content blocks are editable in the CampaignMatches tab of the dashboard.
6. **Tracking & Analytics:** Page views and click-through rates are measured for each CampaignMatch for a clear distinction of segment performance metrics. Individual buttons can also be tagged to measure more granular conversion data for page testing and reports.

Ad Click → UTM in URL → MatchAgent Checks Rules → Match Found → Content Swaps → Result Cached → Analytics Updated

## Caching Logic

### Cache Key Components

The cache key includes: content text, user prompt, URL parameters (like campaign, demographics), and MatchAgent configuration. This ensures that different contexts get different AI responses.

{% hint style="info" %}
**Cache invalidation:** A new cache version is created any time the content text, Custom User Prompt, URL parameters, or MatchAgent configuration changes. This means edits to copy or rules will generate a new variant entry in Analytics. Previous version data is retained for comparison.

**What does NOT trigger a new version:** Visitor traffic volume changes, plan upgrades, or dashboard-only settings that don't affect the MatchAgent configuration.
{% endhint %}
