mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-11-23 23:04:04 +00:00
16 lines
645 B
JavaScript
16 lines
645 B
JavaScript
let GoogleAnalytics = (() => {
|
|
function getGoogleAnalyticsScript(tagId) {
|
|
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,
|
|
isValidTag: isValidTag
|
|
};
|
|
})();
|
|
|
|
module.exports = GoogleAnalytics;
|