Skip to content

Commit a23bf9c

Browse files
UI: Fix for gtag
1 parent 5b4ad29 commit a23bf9c

File tree

7 files changed

+17
-12
lines changed

7 files changed

+17
-12
lines changed

_includes/docs/devices-library/index.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,14 +97,14 @@
9797
}
9898

9999
function reportSearchInput(searchText) {
100-
if (typeof window.dataLayer === "undefined" || !window.dataLayer.push) {
101-
return;
100+
if (checkDataLayer()) {
101+
return;
102102
}
103103

104104
gtag("event", "search", {
105-
"search_term": searchText,
106-
"event_label": "DeviceLibraryGuides",
107-
"searchPageCount": searchPageCount
105+
"search_term": searchText,
106+
"event_label": "DeviceLibraryGuides",
107+
"searchPageCount": searchPageCount
108108
});
109109
}
110110

_includes/docs/guides.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
}
9898

9999
function reportSearchInput(searchText) {
100-
if (typeof window.dataLayer === "undefined" || !window.dataLayer.push) {
100+
if (checkDataLayer()) {
101101
return;
102102
}
103103

_includes/head-header.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@
258258
<script async defer>
259259
function _gaLt(event) {
260260
/* If GTM is blocked or not loaded, or not main|middle|touch click then don't track */
261-
if (typeof window.dataLayer === "undefined" || !window.dataLayer.push || (event.which != 1 && event.which != 2)) {
261+
if (checkDataLayer() || (event.which != 1 && event.which != 2)) {
262262
return;
263263
}
264264
var el = event.srcElement || event.target;

_includes/trendz-wizard.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ <h4 class="step__header">Step 3</h4>
161161
}
162162

163163
function reportTrendzWizrdAction(link, product) {
164-
if (typeof window.dataLayer === "undefined" || !window.dataLayer.push || !link || !product) {
164+
if (checkDataLayer() || !link || !product) {
165165
return;
166166
}
167167

_layouts/plain.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<script type="text/javascript">
2020
function _gaLt(event) {
2121
/* If GTM is blocked or not loaded, or not main|middle|touch click then don't track */
22-
if (typeof window.dataLayer === "undefined" || !window.dataLayer.push || (event.which != 1 && event.which != 2)) {
22+
if (checkDataLayer() || (event.which != 1 && event.which != 2)) {
2323
return;
2424
}
2525
var el = event.srcElement || event.target;

_layouts/pricing.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@
197197
}
198198

199199
function reportPriceLink(link, product) {
200-
if (typeof window.dataLayer === "undefined" || !window.dataLayer.push || !link || !product) {
200+
if (checkDataLayer() || !link || !product) {
201201
return;
202202
}
203203
gtag("event", "PriceLink", {
@@ -207,7 +207,7 @@
207207
}
208208

209209
function reportPriceOpen(solutionId) {
210-
if (typeof window.dataLayer === "undefined" || !window.dataLayer.push || !solutionId) {
210+
if (checkDataLayer() || !solutionId) {
211211
return;
212212
}
213213
gtag("event", "PriceOpen", {

js/script.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ function newDOMElement(tag, className, id){
1717
return el;
1818
}
1919

20+
function checkDataLayer() {
21+
return typeof window.dataLayer === "undefined" || !window.dataLayer.push;
22+
}
23+
2024
function px(n){
2125
return n + 'px';
2226
}
@@ -205,9 +209,10 @@ var tb = (function () {
205209
}
206210

207211
function reportFaqNode(nodeId) {
208-
if (typeof window.dataLayer === "undefined" || !window.dataLayer.push || !nodeId) {
212+
if (checkDataLayer() || !nodeId) {
209213
return;
210214
}
215+
211216
gtag("event", "FaqNode", {
212217
"event_category": nodeId
213218
});

0 commit comments

Comments
 (0)