diff --git a/optify.js b/optify.js
index 565a26b..6222e1a 100644
--- a/optify.js
+++ b/optify.js
@@ -3,16 +3,20 @@
  * Initialize the Optify system.
  */
 
-var _opt = _opt || [];
+(function ($) {
 
-(function($) {
-  $(document).ready(function() {
-    _opt.push([ "view", Drupal.settings.optify.token]);
-    var scr = document.createElement("script");
-    scr.type = "text/javascript";
-    scr.async = true;
-    scr.src = "//service.optify.net/opt-v2.js";
-    var other = document.getElementsByTagName("script")[0];
-    other.parentNode.insertBefore(scr, other);
-  });
-})(jQuery);
+  Drupal.behaviors.optifyTracking = {
+    attach: function (context, settings) {
+      var _opt = _opt || [];
+
+      _opt.push([ "view", ]);
+      var scr = document.createElement("script");
+      scr.type = "text/javascript";
+      scr.async = true;
+      scr.src = "//service.optify.net/opt-v2.js";
+      var other = document.getElementsByTagName("script")[0];
+      other.parentNode.insertBefore(scr, other);
+    }
+  };
+
+})(jQuery);
\ No newline at end of file
