diff --git a/serendipity_event_google_analytics/serendipity_event_google_analytics.php b/serendipity_event_google_analytics/serendipity_event_google_analytics.php
index c27596733..8e6666eb8 100644
--- a/serendipity_event_google_analytics/serendipity_event_google_analytics.php
+++ b/serendipity_event_google_analytics/serendipity_event_google_analytics.php
@@ -154,7 +154,7 @@ function gtag() {
!$markupDisabledConfig && !$markupDisabledPost) {
$element = $element['element'];
$eventData[$element] = preg_replace_callback(
- "#]*)>#isUm",
+ "#]*)>#isUm",
array($this, 'analytics_tracker_callback'),
$eventData[$element]
);
@@ -162,21 +162,32 @@ function gtag() {
}
return true;
- default :
+ default:
return false;
} // end switch ($event) {
}
+ /**
+ * matches:
+ * 0 = entire regexp match
+ * 1 = anything between ""
+ */
function analytics_tracker_callback($matches)
{
- $parsed_url = parse_url($matches[3].$matches[4]);
+ $parsed_url = parse_url($matches[2].$matches[3]);
+
+ // Skip tracking for local URLs without scheme, or unknown scheme.
if (!isset($parsed_url["scheme"]))
- return;
+ return $matches[0];
if (!in_array($parsed_url["scheme"], array("http", "https")))
- return;
+ return $matches[0];
+ // Note: Assume, there is no second onclick-event in substr($matches[0], 2)
return '