diff --git a/src/There4/Analytics/AnalyticsEvent.php b/src/There4/Analytics/AnalyticsEvent.php index 32733d0..36942e3 100644 --- a/src/There4/Analytics/AnalyticsEvent.php +++ b/src/There4/Analytics/AnalyticsEvent.php @@ -93,7 +93,7 @@ public function trackEvent($object, $action, $label = '', $value = 1) $var_cookie = rand(10000000, 99999999); //random cookie number $var_random = rand(1000000000, 2147483647); //number under 2147483647 $var_today = time(); //today - $var_referer = $_SERVER['SCRIPT_URI']; //referer url + $var_referer = $this->getCurrentUrl(); //referer url $var_utmp = 'index.php'; $var_uservar = ''; @@ -143,6 +143,19 @@ public function trackEvent($object, $action, $label = '', $value = 1) return $is_gif; } + + /** + * Get the current Url + * + * @return string current url + */ + public function getCurrentUrl() { + $url = isset( $_SERVER['HTTPS'] ) && 'on' === $_SERVER['HTTPS'] ? 'https' : 'http'; + $url .= '://' . $_SERVER['SERVER_NAME']; + $url .= in_array( $_SERVER['SERVER_PORT'], array('80', '443') ) ? '' : ':' . $_SERVER['SERVER_PORT']; + $url .= $_SERVER['REQUEST_URI']; + return $url; + } } /* End of file AnalyticsEvent.php */