Back to Functions and API

Updated on Nov 05, 2023

How to call the Slimstat tracker from an external function

Sometimes, people need to track specific page views from outside of WordPress, or in situations where the engine is not even invoked (think redirects, for example). These instructions here below show how to achieve this in PHP:

if ( method_exists( 'wp_slimstat', 'slimtrack' ) ) {

Then you can leverage any of the available filters to customize the tracker’s behavior from within your code. For example:

add_filter( 'slimstat_filter_pageview_stat', 'my_redirect_pageview_stat' );

Now, that function can manipulate all the data collected by Slimstat, before it’s saved into the database.