diff --git a/config/install/thunderhead.config.yml b/config/install/thunderhead.config.yml
new file mode 100644
index 0000000..03627cf
--- /dev/null
+++ b/config/install/thunderhead.config.yml
@@ -0,0 +1 @@
+thunderhead:
diff --git a/js/thunderhead.js b/js/thunderhead.js
new file mode 100644
index 0000000..bb99016
--- /dev/null
+++ b/js/thunderhead.js
@@ -0,0 +1,17 @@
+(function (Drupal) {
+  'use strict';
+  Drupal.behaviors.thunderhead = {
+    attach: function (context, settings) {
+
+      var onetag = document.createElement('script');
+      onetag.id = 'thxTag';
+      onetag.type = 'text/javascript';
+      onetag.async = true;
+      onetag.src = 'https://eu2.thunderhead.com/one/rt/js/one-tag.js?siteKey=' + settings.thunderhead.siteKey;
+      var firstScriptElement = document.getElementsByTagName('script')[0];
+      firstScriptElement.parentNode.insertBefore(onetag, firstScriptElement);
+
+    }
+  };
+
+})(Drupal);
diff --git a/src/Form/ConfigForm.php b/src/Form/ConfigForm.php
new file mode 100644
index 0000000..1cbd128
--- /dev/null
+++ b/src/Form/ConfigForm.php
@@ -0,0 +1,59 @@
+<?php
+
+namespace Drupal\thunderhead\Form;
+
+use Drupal\Core\Form\ConfigFormBase;
+use Drupal\Core\Form\FormStateInterface;
+use Drupal\Core\Config\ConfigFactoryInterface;
+use Symfony\Component\DependencyInjection\ContainerInterface;
+
+/**
+ * Class ConfigForm.
+ *
+ * @package Drupal\thunderhead\Form
+ */
+class ConfigForm extends ConfigFormBase {
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function getEditableConfigNames() {
+    return [
+      'thunderhead.config',
+    ];
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getFormId() {
+    return 'thunderhead_config_form';
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function buildForm(array $form, FormStateInterface $form_state) {
+    $config = $this->config('thunderhead.config');
+    $form['thunderhead_site_key'] = [
+      '#type' => 'textfield',
+      '#title' => $this->t('Site Key'),
+      '#maxlength' => 64,
+      '#size' => 64,
+      '#default_value' => $config->get('thunderhead_site_key'),
+    ];
+    return parent::buildForm($form, $form_state);
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function submitForm(array &$form, FormStateInterface $form_state) {
+    parent::submitForm($form, $form_state);
+
+    $this->config('thunderhead.config')
+      ->set('thunderhead_site_key', $form_state->getValue('thunderhead_site_key'))
+      ->save();
+  }
+
+}
diff --git a/thunderhead.admin.inc b/thunderhead.admin.inc
deleted file mode 100644
index 2a6a815..0000000
--- a/thunderhead.admin.inc
+++ /dev/null
@@ -1,45 +0,0 @@
-<?php
-
-/**
- * @file
- *  Admin settings for the Thunderhead module.
- */
-
-/**
- * Thunderhead settings form.
- */
-function thunderhead_settings_form() {
-  $form['thunderhead_settings'] = array(
-    '#type' => 'fieldset',
-    '#title' => t('Thunderhead settings'),
-  );
-
-  $form['thunderhead_settings']['thunderhead_enabled'] = array(
-    '#type' => 'checkbox',
-    '#title' => t('Enable Thunderhead'),
-    '#description' => t('If enabled, Thunderhead scripts will be added to the page head.'),
-    '#default_value' => variable_get('thunderhead_enabled', 0),
-  );
-
-  $form['thunderhead_settings']['thunderhead_site_key'] = array(
-    '#type' => 'textfield',
-    '#title' => t('Thunderhead site key'),
-    '#default_value' => variable_get('thunderhead_site_key', ''),
-  );
-
-  $form['thunderhead_settings']['thunderhead_script_url'] = array(
-    '#type' => 'textfield',
-    '#title' => t('Thunderhead script URL'),
-    '#description' => t('The link to the Thunderhead one-tag.js file, this must be an absolute URL.'),
-    '#default_value' => variable_get('thunderhead_script_url', 'https://eu2.thunderhead.com/one/rt/js/one-tag.js'),
-  );
-
-  $form['thunderhead_settings']['thunderhead_exclude_list'] = array(
-    '#type' => 'textarea',
-    '#title' => t('Thunderhead URL exclude list'),
-    '#description' => t("A comma seperated list of URLs that won't include Thunderhead, do not include the domain name. Format: /url, /url"),
-    '#default_value' => variable_get('thunderhead_exclude_list', ''),
-  );
-
-  return system_settings_form($form);
-}
diff --git a/thunderhead.info b/thunderhead.info
deleted file mode 100644
index 4c7dca0..0000000
--- a/thunderhead.info
+++ /dev/null
@@ -1,5 +0,0 @@
-name = Thunderhead
-description = "Adds the Thunderhead customer engagement scripts to the page head."
-package = User interface
-core = 7.x
-configure = admin/config/user-interface/thunderhead
diff --git a/thunderhead.info.yml b/thunderhead.info.yml
new file mode 100644
index 0000000..4441cbe
--- /dev/null
+++ b/thunderhead.info.yml
@@ -0,0 +1,6 @@
+name: Thunderhead
+type: module
+description: 'Thunderhead integration'
+core: 8.x
+dependencies:
+package: Thunderhead
diff --git a/thunderhead.libraries.yml b/thunderhead.libraries.yml
new file mode 100644
index 0000000..084cdb0
--- /dev/null
+++ b/thunderhead.libraries.yml
@@ -0,0 +1,6 @@
+thunderhead:
+  version: 1.x
+  js:
+    js/thunderhead.js: {}
+  dependencies:
+    - core/drupalSettings
diff --git a/thunderhead.links.menu.yml b/thunderhead.links.menu.yml
new file mode 100644
index 0000000..9e2d2aa
--- /dev/null
+++ b/thunderhead.links.menu.yml
@@ -0,0 +1,6 @@
+thunderhead.thunderhead_config_form:
+  title: 'Thunderhead Config'
+  route_name: thunderhead.thunderhead_config_form
+  description: 'Thunderhead Config'
+  parent: system.admin_config_system
+  weight: 99
diff --git a/thunderhead.module b/thunderhead.module
index 17e2b01..02a86b7 100644
--- a/thunderhead.module
+++ b/thunderhead.module
@@ -2,104 +2,22 @@
 
 /**
  * @file
- * Thunderhead functionality.
+ * Thunderhead integration module.
  */
 
 /**
- * Implements hook_menu().
+ * Implements hook_page_attachments_alter().
  */
-function thunderhead_menu() {
-  $items['admin/config/user-interface/thunderhead'] = array(
-    'title' => 'Thunderhead',
-    'description' => 'Configure the Thunderhead module',
-    'page callback' => 'drupal_get_form',
-    'page arguments' => array('thunderhead_settings_form'),
-    'access arguments' => array('administer thunderhead configuration'),
-    'file' => 'thunderhead.admin.inc',
-  );
+function thunderhead_page_attachments_alter(&$build) {
 
-  return $items;
-}
-
-/**
- * Implements hook_permission().
- */
-function thunderhead_permission() {
-  return array(
-    'administer thunderhead configuration' => array(
-      'title' => t('Administer Thunderhead configuration'),
-      'description' => t('Perform administration tasks for Thunderhead.'),
-    ),
-  );
-}
-
-/**
- * Implements hook_init().
- */
-function thunderhead_init() {
-  $script_url = variable_get('thunderhead_script_url');
-  $site_key = variable_get('thunderhead_site_key');
-  $thunderhead_enabled = variable_get('thunderhead_enabled');
+  $is_admin = \Drupal::service('router.admin_context')->isAdminRoute();
 
-  $path = current_path();
-  // Ignore admin pages.
-  if (!path_is_admin($path)) {
-    // Only include Thunderhead if it has been configured, and is enabled.
-    if ($thunderhead_enabled && !empty($script_url) && !empty($site_key)) {
-      $exclude_list = variable_get('thunderhead_exclude_list', '');
+  if (!$is_admin) {
+    $site_key = \Drupal::config('thunderhead.config')
+      ->get('thunderhead_site_key');
 
-      $exclude_list_array = array();
-      if (!empty($exclude_list)) {
-        // Create an array of the excluded URLs and trim any whitespace.
-        $exclude_list_array = array_map('trim', explode(',', $exclude_list));
-      }
-
-      // Don't include Thunderhead on URLs in the exclude list.
-      if (!in_array(request_uri(), $exclude_list_array)) {
-        // Build the Thunderhead script link.
-        $link_attributes = array(
-          '#type' => 'html_tag',
-          '#tag' => 'link',
-          '#attributes' => array(
-            'rel' => 'preload',
-            'href' => $script_url . '?siteKey=' . $site_key,
-            'as' => 'script',
-          ),
-          '#weight' => '-9999',
-        );
-
-        // Add the script link to the head.
-        drupal_add_html_head($link_attributes, 'thunderhead_link');
-
-        // Build the Thunderhead inline JS.
-        $script = "(function(d,s,b,k){var t=d.createElement(s),f=d.getElementsByTagName(s)[0];t.id='thxTag';t.src=b+'";
-        $script_url_parts = parse_url($script_url);
-        $script .= $script_url_parts['path'] . "?siteKey='+k;f.parentNode.insertBefore(t,f);})";
-        $script .= "(document,'script','" . $script_url_parts['scheme'] . '://' . $script_url_parts['host'] . "','" . $site_key . "')";
-
-        drupal_add_js($script, array(
-          'type' => 'inline',
-          'scope' => 'header',
-        ));
-      }
-    }
+    $build['#attached']['library'][] = 'thunderhead/thunderhead';
+    $build['#attached']['drupalSettings']['thunderhead']['siteKey'] = $site_key;
   }
-}
 
-/**
- * Implements hook_help().
- */
-function thunderhead_help($path, $arg) {
-  switch ($path) {
-    case 'admin/help#thunderhead':
-      $output = '<h2>' . t('Thunderhead') . '</h2>';
-      $output .= '<p>' . t("The Thunderhead module includes the Thunderhead script to all site pages if configured") . '<p>';
-      $output .= '<h3>' . t('Configuration') . '</h3>';
-      $output .= '<ul><li>' . t("Configure user permissions for Thunderhead") . '</li>';
-      $output .= '<li>' . t("Enable the Thunderhead option") . '</li>';
-      $output .= '<li>' . t("Enter the Thunderhead script URL") . '</li>';
-      $output .= '<li>' . t("Enter the Thunderhead site key") . '</li>';
-      $output .= '<li>' . t("Include any URLs to be excluded") . '</li></ul>';
-      return $output;
-  }
 }
diff --git a/thunderhead.routing.yml b/thunderhead.routing.yml
new file mode 100644
index 0000000..ff201bc
--- /dev/null
+++ b/thunderhead.routing.yml
@@ -0,0 +1,10 @@
+
+thunderhead.thunderhead_config_form:
+  path: '/admin/config/thunderhead/config'
+  defaults:
+    _form: '\Drupal\thunderhead\Form\ConfigForm'
+    _title: 'Thunderhead Config'
+  requirements:
+    _permission: 'access administration pages'
+  options:
+    _admin_route: TRUE
