Skip to content

Commit

Permalink
Refactor: Move gtmEvent() and loadGoogleAnalytics4() into 'googleAnal…
Browse files Browse the repository at this point in the history
…ytics4' module
  • Loading branch information
astik-dev committed Apr 20, 2024
1 parent e86d1fa commit 1797ee9
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/js/cookies.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { doc, dqs } from "./modules/utils.js";

import { getCookie } from "./modules/cookies.js";
import { addCookiesPopup } from "./modules/cookies-popup.js";
import { loadGoogleAnalytics4 } from "./modules/loadGoogleAnalytics4.js";
import { loadGoogleAnalytics4 } from "./modules/googleAnalytics4.js";


doc.addEventListener('DOMContentLoaded', function() {
Expand Down
8 changes: 1 addition & 7 deletions src/js/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { doc, dqs, dqsa } from "./modules/utils.js";
import imageCreator from "./modules/imageCreator.js";
import spreadsheets from "./modules/spreadsheets.js";
import { gtmEvent } from "./modules/googleAnalytics4.js";



Expand Down Expand Up @@ -415,13 +416,6 @@ function generateContacts(contacts) {



function gtmEvent(object) {
if (typeof dataLayer !== "undefined" && Array.isArray(dataLayer)) {
dataLayer.push(object);
}
}



function smoothScroll(elemSelector) {
const startY = window.pageYOffset;
Expand Down
2 changes: 1 addition & 1 deletion src/js/modules/cookies-popup.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { dqs, dqsa } from "./utils.js";
import { setCookie } from "./cookies.js";
import { loadGoogleAnalytics4 } from "./loadGoogleAnalytics4.js";
import { loadGoogleAnalytics4 } from "./googleAnalytics4.js";


const cookiesPopupHTML = `
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,9 @@ export function loadGoogleAnalytics4 () {
// Google Tag Manager (noscript)
doc.body.insertAdjacentHTML('afterbegin', `<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-5LL8BFL" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>`);
}

export function gtmEvent(object) {
if (typeof dataLayer !== "undefined" && Array.isArray(dataLayer)) {
dataLayer.push(object);
}
}

0 comments on commit 1797ee9

Please sign in to comment.