# Install on WordPress

Canonical: https://sourcetag.io/docs/install-wordpress

The WordPress plugin loads the tracking script on your site and can set server-side cookies so Safari doesn't strip your attribution data after 7 days.

## Step 1: Install the plugin

1. In WordPress, go to Plugins > Add New Plugin
2. Search for **SourceTag**
3. Click Install Now on **SourceTag – Lead Source Tracking for Forms**, then Activate

You can also download it from the [WordPress.org plugin directory](https://wordpress.org/plugins/sourcetag/) and upload it under Plugins > Add New Plugin > Upload Plugin.

Updates come through WordPress like any other plugin, so you'll see new versions on your Plugins and Updates screens.

## Step 2: Enter your Script URL

1. Go to Settings > SourceTag
2. Paste your Script URL (found on your site's detail page in the SourceTag dashboard). It looks like `https://cdn.sourcetag.io/scripts/YOUR_SITE_ID/st.js`
3. Click Save Changes

The plugin now loads the tracking script on every page of your site.

## Step 3: Enable server-side cookies (optional)

Safari, Brave, and other privacy-focused browsers limit JavaScript cookies to 7 days. If your sales cycle is longer than a week, enable server-side cookies:

1. In Settings > SourceTag, tick **Enable server-side cookie setting**
2. Save Changes

This makes the plugin re-set the attribution cookie via PHP `setcookie()` on every page load. Safari treats HTTP-header-set cookies as server cookies, allowing up to 400 days of persistence.

## Step 4: Test

1. Visit your site with UTM parameters: `?utm_source=test&utm_medium=cpc`
2. Submit any form on your site
3. Check the form notification email. You should see hidden fields like `st_fc_channel`, `st_lc_source`, etc.

## Compatible form builders

The plugin works with any WordPress form builder:

- Contact Form 7
- Gravity Forms
- WPForms
- Elementor Forms
- Formidable Forms
- Ninja Forms
- Any form that renders standard HTML `<form>` elements

You'll need to add hidden fields to your forms for the attribution data you want to capture. SourceTag detects forms on the page and populates any matching hidden fields on submission. See [Add Hidden Fields](https://sourcetag.io/docs/fields-html) for the field names.

## Troubleshooting

**Hidden fields not appearing:** Make sure your forms have hidden fields with the correct field names (see [Add Hidden Fields](https://sourcetag.io/docs/fields-html)). Also check the Script URL is correct and your site has been added in the SourceTag dashboard. View the page source to confirm the script tag is present.

**Server-side cookies not working:** The cookie refresh happens on PHP's `init` hook, before any output. If you're using full-page caching (WP Rocket, W3 Total Cache), the PHP hook may not run on cached pages. Exclude pages with forms from the cache, or configure the cache to pass cookies through.
