> ## Documentation Index
> Fetch the complete documentation index at: https://docs.wisepilot.app/llms.txt
> Use this file to discover all available pages before exploring further.

# WordPress & Elementor

> Connect your WordPress site for content import, publishing, and attribution tracking.

The WordPress integration enables two-way content flow and attribution tracking between WisePilot and your WordPress/Elementor website.

## Prerequisites

* WordPress site with Elementor installed
* Advanced Custom Fields (ACF) plugin installed
* Admin access to WordPress

## Connecting WordPress

1. Navigate to **Integrations -> WordPress**
2. Enter your WordPress site URL
3. Authenticate with your WordPress credentials or API key

Once connected, you can import existing content and publish new content from WisePilot.

## Plugin Installation

The WisePilot plugin (v3.0+) bundles everything you need in a single download:

* Attribution tracking (cr\_attrib cookie + link rewriting)
* CTA view and click tracking (no GTM required)
* Direct event delivery to WisePilot API
* GA4 dual-write (automatic if GA4 is installed)
* GHL form field injection
* RankMath SEO field exposure
* ACF CTA field group management

### Install Steps

1. Go to **Integrations -> WordPress** in WisePilot
2. Click **Download Plugin** to get the ZIP file
3. In WordPress admin, go to **Plugins -> Add New -> Upload Plugin**
4. Upload the ZIP and activate
5. The plugin auto-configures when your site is connected

<Note>The plugin auto-generates a tracking token on download. This token authenticates event delivery from your site to WisePilot. No manual configuration is needed.</Note>

### How Auto-Configuration Works

When you connect WordPress in WisePilot, the app calls your plugin's REST endpoint (`/wp-json/cr/v1/configure`) to set:

* `cr_website_id` — your WisePilot website UUID
* `cr_events_url` — the WisePilot API base URL
* `cr_tracking_token` — per-site authentication token

These are stored in `wp_options` and injected into the attribution script via `wp_localize_script`.

### Verifying Configuration

1. Visit any page on your site
2. View page source and search for `crConfig`
3. You should see a script block with `websiteId`, `eventsUrl`, and `trackingToken`

Or check plugin status in WordPress admin via the REST API: `GET /wp-json/cr/v1/status`

## Content Import

Import your existing WordPress content into WisePilot:

* Blog posts and pages are imported with their metadata
* Content is analyzed for performance optimization
* Existing content can be refreshed or repurposed using AI generation

## CTA Data Attributes

In Elementor, CTA elements need these data attributes for tracking:

| Attribute               | Value         | Example                             |
| ----------------------- | ------------- | ----------------------------------- |
| `data-cta-id`           | UUID          | `a1b2c3d4-...`                      |
| `data-cta-position`     | Position code | `abtf`, `exit`, `footer`, `sidebar` |
| `data-asset-content-id` | Content ID    | `CNT-123`                           |

The plugin tracks CTA views (via IntersectionObserver at 50% visibility) and clicks (via event delegation) automatically for any element with `data-cta-id`.

## ACF Field Setup

WisePilot uses Advanced Custom Fields to store CTA data on your WordPress pages.

1. Go to **Integrations -> WordPress**
2. Click **"Check ACF Fields"**
3. Review which fields exist vs. missing
4. Create missing fields automatically or manually

### Required Fields

Each CTA position (abtf, exit, footer, sidebar) needs 13 fields:

`{position}_headline_text`, `{position}_subheadline_text`, `{position}_button_text`, `{position}_cta_subtext`, `{position}_cta_url`, `{position}_main_image`, `{position}_cta_id`, `{position}_utm_source`, `{position}_utm_medium`, `{position}_utm_campaign`, `{position}_utm_content`, `{position}_utm_term`, `{position}_cta_full_url`

## Testing

1. Visit a page with CTAs
2. Open browser DevTools -> Network tab
3. Scroll to a CTA — you should see a POST to `/api/integrations/cr/events`
4. Click a CTA — another event fires immediately
5. Inspect CTA links — verify `cr_attrib` parameter is appended
6. If GA4 is installed, check GA4 DebugView for `cta_view` and `cta_click` custom events

## Troubleshooting

### Events not arriving in WisePilot

* Verify plugin is activated and `crConfig` appears in page source
* Check that `websiteId`, `eventsUrl`, and `trackingToken` are all populated (not empty strings)
* Check browser Network tab for failed requests to `/api/integrations/cr/events`
* Verify the tracking token matches what's in your `wordpress_config` table

### CTAs not getting cr\_attrib

* Verify CTA elements have `[data-cta-id]` or `.cr-cta` class
* Check that links are absolute URLs or same-origin paths
* Call `window.getAttributionId()` in the console — it should return a UUID

### ACF fields not saving

* Verify ACF plugin is active
* Check field group is assigned to correct post type
* Verify field names match exactly (case-sensitive)

### Upgrading from v2.x

If you were previously using the GTM-based tracking setup:

1. Download and install the v3.0 plugin (replaces v2.x)
2. GTM CTA tracking tags are no longer needed — you can remove them
3. The attribution script now handles everything directly
4. Your existing tracking data is preserved — new events use `cr_plugin` source
