Install on WordPress

Replace bw_pk_… with your project's public key from the dashboard's Install page. The key only identifies the project; there is no secret in the page.

<?php
// functions.php of your (child) theme
add_action('wp_enqueue_scripts', function () {
  wp_enqueue_script('backwire', 'https://cdn.backwire.io/v1/widget.js', [], null, true);
});
add_filter('script_loader_tag', function ($tag, $handle) {
  if ($handle === 'backwire') {
    $tag = str_replace('<script ', '<script async data-backwire="bw_pk_…" ', $tag);
  }
  return $tag;
}, 10, 2);

Content-Security-Policy

script-src  'self' https://cdn.backwire.io https://challenges.cloudflare.com;
connect-src 'self' https://api.backwire.io;
frame-src   https://challenges.cloudflare.com;

No style-src 'unsafe-inline' is needed: the widget styles itself inside a closed shadow root with constructable stylesheets.

Single-page apps

Route changes made with pushState are detected automatically. From code: window.backwire.open(), window.backwire.close(), window.backwire.identify({ email }) for signed-in users.