One of the major benefits of Logtivity is that it can track all your WordPress sites from one dashboard. It is possible to install Logtivity like a normal WordPress plugin.
However, if you have many sites or a multisite network, there are faster ways to configure all the Logtivity settings via the WordPress admin area.
It is possible to use code to activate Logtivity and manage the initial set-up. 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:
if (class_exists('Logtivity_Register_Site')) {
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
There are four steps to using this code on your sites:
- Install the Logtivity plugin on your sites. If you’re interested in speed, you can use WP-CLI or a site management tool that enables you to install the Logtivity plugin.
- Add this code to your sites using a plugin or your theme’s functions.php file.
- Run this code by visiting your site.
- Go to your Logtivity dashboard and confirm that the site has been added correctly.
Please note that your Site API Key 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.
How to use this code on multisite networks
This code will work on your multisite networks. Each site will be added as a unique site inside your Logtivity dashboard.
- Make sure the Logtivity plugin is set to “Network Active”.
- Place your code or custom plugin inside the main /wp-content/ folder for the multisite network.
- If a site in your networks isn’t visited often, go to the frontend or admin area of that site. This will force the Logtivity code to run.
Click here for a full guide to using Logtivity on multisite networks.