WordPress integration guide

Add BugSnag error monitoring to your WordPress applications.

New to BugSnag? Create an account

Looking for performance monitoring? See our performance guide

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.

You can find your API key in Project Settings 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.

If you want to see error messages on the page, BugSnag exception handlers can be disabled by setting the BUGSNAG_SET_EXCEPTION_HANDLERS constant to false. Exceptions will still be reported to BugSnag, but will have less context and so it is not recommended to be set on production environments.

Reporting handled exceptions

Reporting handled exceptions can be accomplished as follows:

try {
    // Some potentially crashy code
} catch (Exception $e) {
    $bugsnagWordpress->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->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->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->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 Build API guide for more details.

Next steps