diff --git a/tracker/src/p.js b/tracker/src/p.js
index 55edddcaad90979ac60250872c2924a1e8dd7248..c675bc409a2fceb636ada1a46220ec02b638c4d8 100644
--- a/tracker/src/p.js
+++ b/tracker/src/p.js
@@ -2,9 +2,11 @@
 // with some early customers. This script uses a cookie but this was an old version of Plausible.
 // Current script can be found in the tracker/src/plausible.js file
 
-(function(window, plausibleHost){
+(function(){
   'use strict';
 
+  var plausibleHost = new URL(scriptEl.src).origin
+
   function setCookie(name,value) {
     var date = new Date();
     date.setTime(date.getTime() + (3*365*24*60*60*1000)); // 3 YEARS
@@ -117,4 +119,4 @@
   } catch (e) {
     new Image().src = plausibleHost + '/api/error?message=' +  encodeURIComponent(e.message);
   }
-})(window, '<%= base_url %>');
+})();