2023-01-10 20:25:45 +00:00
|
|
|
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>";
|
|
|
|
}
|
2023-01-11 21:44:31 +00:00
|
|
|
function isValidTag(tagInput) {
|
|
|
|
const re = /^\w{1,2}-\d{8}$/g;
|
|
|
|
return tagInput.match(re) != null;
|
|
|
|
}
|
2023-01-10 20:25:45 +00:00
|
|
|
return {
|
2023-01-11 21:44:31 +00:00
|
|
|
getGoogleAnalyticsScript: getGoogleAnalyticsScript,
|
|
|
|
isValidTag: isValidTag
|
2023-01-10 20:25:45 +00:00
|
|
|
};
|
|
|
|
})();
|
|
|
|
|
|
|
|
module.exports = GoogleAnalytics;
|