Is your feature request related to a problem?
The tracker script URL is currently hardcoded in Parsely::get_tracker_url():
$tracker_url = 'https://cdn.parsely.com/keys/' . $this->get_site_id() . '/p.js';
There is no supported way to override this URL. Publishers who serve the Parse.ly tracker in a non-standard manner currently have no clean option — they must either suppress the built-in tracker entirely via wp_parsely_load_js_tracker and re-enqueue it manually, or use the generic WordPress script_loader_src filter as a workaround. Neither is a great solution.
Describe the solution you'd like
GUI
Add a text box on the Advanced tab of the settings page. It's used instead of the default if specified.
Include appropriately prominent disclaimers.
Code-based
Add a wp_parsely_tracker_url filter to get_tracker_url(), consistent with the plugin's existing filter conventions:
public function get_tracker_url(): string {
if ( $this->site_id_is_set() ) {
$tracker_url = 'https://cdn.parsely.com/keys/' . $this->get_site_id() . '/p.js';
/**
* Filters the URL of the Parse.ly tracker script.
*
* @since TBD
*
* @param string $tracker_url The URL of the tracker script.
*/
return esc_url( apply_filters( 'wp_parsely_tracker_url', $tracker_url ) );
}
return '';
}
This would allow publishers to override the URL cleanly:
add_filter( 'wp_parsely_tracker_url', function( string $url ): string {
return 'https://my-first-party-cdn.example.com/p.js';
} );
The filter, if added, takes precedence over the option set by the GUI
Describe alternatives you've considered
- Using
script_loader_src to intercept the registered script — works but is indirect and fragile.
- Using
wp_parsely_load_js_tracker to suppress the built-in tracker and re-enqueuing manually — works but requires the implementor to also replicate the data-parsely-site attribute and id="parsely-cfg" tag mutations, as well as re-enqueuing wp-parsely-loader.
Is your feature request related to a problem?
The tracker script URL is currently hardcoded in
Parsely::get_tracker_url():There is no supported way to override this URL. Publishers who serve the Parse.ly tracker in a non-standard manner currently have no clean option — they must either suppress the built-in tracker entirely via
wp_parsely_load_js_trackerand re-enqueue it manually, or use the generic WordPressscript_loader_srcfilter as a workaround. Neither is a great solution.Describe the solution you'd like
GUI
Add a text box on the
Advancedtab of the settings page. It's used instead of the default if specified.Include appropriately prominent disclaimers.
Code-based
Add a
wp_parsely_tracker_urlfilter toget_tracker_url(), consistent with the plugin's existing filter conventions:This would allow publishers to override the URL cleanly:
The filter, if added, takes precedence over the option set by the GUI
Describe alternatives you've considered
script_loader_srcto intercept the registered script — works but is indirect and fragile.wp_parsely_load_js_trackerto suppress the built-in tracker and re-enqueuing manually — works but requires the implementor to also replicate thedata-parsely-siteattribute andid="parsely-cfg"tag mutations, as well as re-enqueuingwp-parsely-loader.