mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-09-18 01:16:54 +08:00
Feature - Google Analytics - Use Regex to validate UA as per https://support.google.com/analytics/answer/9310895
This commit is contained in:
@@ -3,8 +3,13 @@ let GoogleAnalytics = (() => {
|
||||
return "<script async src=\"https://www.googletagmanager.com/gtag/js?id=" + tagId + "\"></script>" +
|
||||
"<script>window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date());gtag('config', '" + tagId + "'); </script>";
|
||||
}
|
||||
function isValidTag(tagInput) {
|
||||
const re = /^\w{1,2}-\d{8}$/g;
|
||||
return tagInput.match(re) != null;
|
||||
}
|
||||
return {
|
||||
getGoogleAnalyticsScript: getGoogleAnalyticsScript
|
||||
getGoogleAnalyticsScript: getGoogleAnalyticsScript,
|
||||
isValidTag: isValidTag
|
||||
};
|
||||
})();
|
||||
|
||||
|
Reference in New Issue
Block a user