One of the major benefits of Logtivity is that it can track all your WordPress sites from one dashboard. However, if you have many sites, it can be a slow process to install the Logtivity plugin and configure all the settings via the WordPress admin area.
It is possible to use code to activate Logtivity and manage the settings. This code sample below can be added to your theme’s functions.php file, or to a plugin. Please make sure to replace the second line with your Team API key:
Logtivity_Register_Site::execute([ 'team_api_key' => 'ENTER_YOUR_TEAMS_API_KEY_HERE', 'logtivity_disable_default_logging' => false, 'logtivity_should_store_user_id' => true, 'logtivity_should_store_ip' => true, 'logtivity_should_log_profile_link' => true, 'logtivity_should_log_username' => true, 'logtivity_enable_debug_mode' => false, ]);
How to use this code
Make sure the Logtivity plugin is installed on your site and then run this code. You do not need do anything else.
When this code runs, your site will be automatically connected to your Logtivity dashboard and the settings will be configured inside your WordPress admin area.
Please note that your site API won’t work here. You will need the Team API Key. To get your Team API Key, click the “Team Settings” link inside the Logtivity app. Logtivity does also give you API keys for individual sites, but we do recommend using this Team API Key when following this guide.