Lead Source Tracking

#Overview

WP Fusion includes the ability to detect lead sources in URL parameters, such as those used with Google Analytics.

The system is quite versatile. It can look for a variety of common lead source parameters passed in URLs to your site and store these as a cookie when the user first visits your site.

If a visitor then registers on your site, makes a purchase, or submits a WP Fusion enabled form, the detected lead source parameters can be synced to custom fields in any one of WP Fusion’s 40+ supported CRMs and marketing automation platforms.

The cookie is valid for 90 days. So even if a user leaves your site and comes back later to make a purchase, you can still capture the source that brought them to you in the first place.

#Google Analytics

If you’re using Google Analytics’ Campaign URL Builder, Google will generate tracking links to your site that look like https://mysite.com/?utm_source=facebook&utm_campaign=summer_ad.

You can enable each of the various Google Analytics tracking variable for sync from the Contact Fields tab in the WP Fusion settings.

Note: By default WP Rocket caches URLs with Analytics leadsource variables in them. This will prevent WP Fusion’s lead source tracking from working. You can follow this tutorial to exclude the Google query string parameters from WP Rocket’s cache, or enable JS Lead Source Tracking from the settings.

#Custom Lead Source Tracking

To enable custom lead source tracking, locate the leadsource field in the Contact Fields list and map it to a field in your CRM. Make sure to check the Sync box to enable the connection.

Structure the URL to your site like https://mysite.com/?leadsource=custom_leadsource. Anything after the leadsource parameter in the URL will be synced. Using this method you can set up your own lead source tracking strategy however you see fit.

#Referrer, Landing Page and Current Page

The fields Original Referrer, Landing Page and Current Page are a bit different in that they don’t use a URL parameter for tracking.

  • Original Referrer: This tracks the URL a user followed to get to your site. If this is enabled, the referrer URL will be recorded on their first visit.
  • Landing Page: This tracks the page the visitor landed on when they came to your site for the first time.
  • Current Page: This is the page the visitor was on when the form was submitted.

#How it works

When a visitor lands on your site with one of the tracked parameters, WP Fusion will set a cookie, either wpf_leadsource (for the UTM and URL parameters) or wpf_ref for the Original Referrer and Landing Page.

You can see the cookies set by WP Fusion using your browser’s developer tools. If the cookies aren’t being set, your page is probably cached.

This cookie is valid for 90 days. If any any time during that period, a contact record is created for that visitor by WP Fusion, the tracked values will be extracted from the cookie and merged into the API data sent to create the new contact record.

This works any time WP Fusion creates a contact record— a form submission, abandoned cart, product purchase, or regular registration. It does not work when a contact record is added to your CRM by another plugin, since other plugins wouldn’t know to look for cookies set by WP Fusion.

Also note that WP Fusion only sync the lead source data when a new contact record is created. It won’t send the data to an existing contact record, to avoid overwriting lead source data you may have already collected for a contact. This can be considered First Referrer tracking.

#Caching

Note that the lead source tracking relies on cookies, which often aren’t compatible with caching. To get around this, WP Fusion includes an option to set the lead source tracking cookies via Javascript.

If you find that the tracking cookies aren’t being set, try enabling JS Lead Source Tracking from the Advanced tab in the WP Fusion settings.

#Developers

#Register additional leadsource variables

You may want to register additional URL parameters that should be tracked as leadsource variables. You can do this using the wpf_leadsource_vars filter.

For example to register the URL parameter lang:

function my_wpf_custom_leadsource_vars( $vars ) {
	$vars[] = 'lang';
	return $vars;
}

add_filter( 'wpf_leadsource_vars', 'my_wpf_custom_leadsource_vars' );

Once the variable is registered it will be detected in the URL when someone visits your site (for example &lang=en) and saved to the wpf_contact cookie.

Any custom leadsource fields added via the wpf_leadsource_vars filter will automatically show up on the Contact Fields list for syncing with custom fields in your CRM:

Then, when WP Fusion adds a contact record to your CRM (via a registration, purchase, form submission, or any other source), the custom leadsource values will be synced to the corresponding custom fields in your CRM.

If needed you can change the name of the cookies that are used for WP Fusion’s lead source tracking. The two filters are wpf_leadsource_cookie_name and wpf_ref_cookie_name.

For example to prefix the two cookie names with an underscore:

add_filter( 'wpf_leadsource_cookie_name', function() {
	return '_wpf_leadsource';
} );

add_filter( 'wpf_referral_cookie_name', function() {
	return '_wpf_ref';
} );

Was this helpful?