diff --git a/googleanalytics.module b/googleanalytics.module
index 1069c3a..e42a2a9 100644
--- a/googleanalytics.module
+++ b/googleanalytics.module
@@ -16,9 +16,16 @@ function googleanalytics_page_build(&$page) {
   // Seems like the attached isn't working, possibly because this is in-line code
   // $page['#attached']['js'][$script] = array('every_page' => TRUE);
 
-  drupal_add_js(_googleanalytics_get_code($googleanalytics_tracking_id),
-    array('type' => 'inline', 'scope' => 'footer', 'weight' => 5)
+  $options = array(
+    'type' => 'inline',
+    'scope' => 'footer',
+    'weight' => 5,
+    'attributes' => array(
+      'type' => 'text/javascript'
+    )
   );
+
+  drupal_add_js(_googleanalytics_get_code($googleanalytics_tracking_id), $options);
 }
 
 /**
@@ -42,9 +49,7 @@ function googleanalytics_menu() {
  */
 
 function _googleanalytics_get_code($tracking_id) {
-  $code = "<script type=\"text/javascript\">
-
-  var _gaq = _gaq || [];
+  $code = "var _gaq = _gaq || [];
   _gaq.push(['_setAccount', '$tracking_id']);
   _gaq.push(['_trackPageview']);
 
@@ -52,9 +57,7 @@ function _googleanalytics_get_code($tracking_id) {
     var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
     ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
     var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
-  })();
-
-  </script>";
+  })();";
 
   return $code;
 }
