WordPress integration guide

Add Bugsnag error monitoring to your WordPress applications.

Installation

Open the Add New page inside the Plugins section of your WordPress admin dashboard, search for Bugsnag and click Install Now.

Manual Installation

Download and unzip the latest bugsnag.zip.

Upload the bugsnag folder using ftp or scp to the wp-content/plugins folder of your WordPress site.

Basic configuration

  • Click Activate Plugin to activate the plugin.

  • Click Configure and enter your Bugsnag API Key from your Bugsnag Dashboard.

Reporting unhandled exceptions

At this point, Bugsnag should be installed and configured, and any unhandled exceptions will be automatically detected and should appear in your Bugsnag dashboard.

Reporting handled exceptions

Reporting handled exceptions can be accomplished as follows:

try {
    // Some potentially crashy code
} catch (Exception $e) {
    $bugsnagWordpress->client->notifyException($e);
}

When reporting handled exceptions, it’s often helpful to send us custom diagnostic data or to adjust the severity of particular errors. For more information, see reporting handled errors.

Sending diagnostic data

Automatically captured diagnostics

Bugsnag will automatically capture the following data for every exception:

  • A full stacktrace
  • Request information, including ip, headers, URL, HTTP method, and HTTP params
  • Session and cookie data
  • Release stage (production, beta, staging, etc)
  • Hostname

Custom diagnostics

It is often helpful to send us additional application-specific diagnostic data. This can be accomplished as follows:

$bugsnagWordpress->client->setBeforeNotifyFunction(function ($error) {
    $error->setMetaData([
      'account' => [
          'name' => 'Acme Co.',
          'paying_customer' => true,
      ]
    ]);
});

For more information, see the customizing error reports reference.

Identifying users

In order to correlate errors with customer reports, or to see a list of users who experienced each error, it is helpful to capture and display user information on your Bugsnag dashboard.

You can set this information as follows:

$bugsnagWordpress->client->setUser([
    'id' => '123456',
    'name' => 'Leeroy Jenkins',
    'email' => 'leeeeroy@jenkins.com',
]);

You can also set this on the error object from the callback function from v2.9 and upwards:

$bugsnagWordpress->client->setBeforeNotifyFunction(function ($error) {
    $error->setUser([
        'id' => '123456',
        'name' => 'Leeroy Jenkins',
        'email' => 'leeeeroy@jenkins.com',
    ]);
});

For more information, see configuration options.

Tracking deploys

By sending your source revision or application version to us when you deploy a new version of your app, you’ll be able to see which deploy each error was introduced in, or seen in.

See our deploy tracking guide for more details.

Next steps