diff --git a/includes/klaviyo.admin.inc b/includes/klaviyo.admin.inc
index 040ad8b..7d02b7b 100644
--- a/includes/klaviyo.admin.inc
+++ b/includes/klaviyo.admin.inc
@@ -48,5 +48,38 @@ function klaviyo_api_integration_settings() {
     );
   }
 
+  $js_settings = variable_get('klaviyo_javascript', array('key_public' => '', 'roles' => array()));
+  $form['klaviyo_javascript'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Javascript API'),
+    '#description' => t('ADD SOME DESCRIPTION HERE TO EXPLAIN JS VS SERVER API.'),
+    '#collapsible' => TRUE,
+    '#tree' => TRUE
+  );
+
+  $form['klaviyo_javascript']['key_public'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Public API key'),
+    '#description' => t('The public API key is used in order to send events via the JavaScript integration. The javascript will not be added if the public key is missing. The public key can be retrieved from Account >> Settings >> <a href="!url">API Keys</a> from within Klaviyo.',
+      array('!url' => 'https://www.klaviyo.com/account#api-keys-tab')
+    ),
+    '#default_value' => $js_settings['key_public'],
+    '#size' => 60,
+    '#maxlength' => 128,
+    '#required' => FALSE,
+    '#group' => 'klaviyo',
+  );
+
+  // @todo: Add ability for black list vs white list.
+  $form['klaviyo_javascript']['roles'] = array(
+    '#type' => 'checkboxes',
+    '#title' => t('Remove script for specific roles'),
+    '#default_value' => $js_settings['roles'],
+    '#options' => user_roles(),
+    '#description' => t('Remove script only for the selected role(s). If none of the roles are selected, all roles will have the script. Otherwise, any roles selected here will NOT have the script.'),
+  );
+
+  // @todo: Add ability to exclude on certain pages.
+
   return system_settings_form($form);
 }
diff --git a/klaviyo.module b/klaviyo.module
index 9fe581c..f1ebda8 100644
--- a/klaviyo.module
+++ b/klaviyo.module
@@ -520,3 +520,61 @@ function klaviyo_get_installation_instructions() {
     '!drupal_project_page' => 'https://www.drupal.org/project/klaviyo#klaviyo-installation',
   ));
 }
+
+/**
+ * Implementation of hook_page_alter().
+ */
+function klaviyo_page_alter(&$page) {
+  global $user;
+
+  $settings = variable_get('klaviyo_javascript', array());
+  if (!empty($settings['key_public']) && _klaviyo_js_should_add_js($user)) {
+
+    if ($user->mail) {
+      $identify = "_learnq.push(['identify', {" .
+                   "'\$email' : '" . $user->mail . "'" .
+                    "}]);";
+    }
+    else {
+      $identify = '';
+    }
+
+    $script = "var _learnq = _learnq || [];" .
+              "_learnq.push(['account', '" . $settings['key_public'] . "']);" .
+              $identify .
+              "(function () {" .
+              "var b = document.createElement('script'); b.type = 'text/javascript'; b.async = true;" .
+              "b.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'a.klaviyo.com/media/js/analytics/analytics.js';" .
+              "var a = document.getElementsByTagName('script')[0]; a.parentNode.insertBefore(b, a);" .
+              "})();";
+
+    drupal_add_js($script, array(
+      'scope' => 'footer',
+      'type' => 'inline',
+      'weight' => 0
+      )
+    );
+  }
+}
+
+/**
+ * Determine if the JS tracking snippet should be added to a page.
+ *
+ * @param object $account
+ *   (optional) The user account to check, if not given use currently logged in user.
+ * @return boolean
+ *   Returns TRUE if the JS tracking snippt should be added to a page and FALSE
+ *   otherwise.
+ */
+function _klaviyo_js_should_add_js($account = NULL) {
+  if (is_null($account)) {
+    global $user;
+    $account = $user;
+  }
+
+  $js_settings = variable_get('klaviyo_javascript', array());
+  $roles = !empty($js_settings['roles']) ? $js_settings['roles'] : array();
+  $role_intersection = array_intersect_key($account->roles, array_flip($js_settings['roles']));
+
+  return empty($role_intersection);
+}
