@mahe_pkm/buzl-capi 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Buzl_GoogleAppsScript_Template.gs +948 -948
- package/CHANGELOG.md +118 -83
- package/LICENSE +21 -21
- package/README.md +339 -253
- package/USER_HANDBOOK.html +808 -0
- package/USER_HANDBOOK.md +842 -0
- package/assets/js/buzl-tracking.js +390 -390
- package/bin/cli.js +175 -155
- package/package.json +3 -1
- package/src/cli/terminal.js +389 -388
- package/src/core/injector.js +321 -321
- package/src/core/rollback.js +281 -281
- package/src/core/scanner.js +506 -506
- package/src/core/tester.js +666 -357
- package/src/gui/public/app.js +915 -87
- package/src/gui/public/index.html +620 -230
- package/src/gui/public/style.css +1603 -509
- package/src/gui/server.js +242 -232
- package/src/index.js +47 -47
- package/src/templates/GoogleAppsScript.gs +948 -948
- package/src/templates/buzl-tracking.js +475 -475
- package/src/templates/gtm-meta-snippets.js +149 -149
|
@@ -1,149 +1,149 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* GTM & Meta Pixel Snippet Generators
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
const HEAD_START_MARKER = '<!-- BUZL_TRACKING_HEAD_START -->';
|
|
6
|
-
const HEAD_END_MARKER = '<!-- BUZL_TRACKING_HEAD_END -->';
|
|
7
|
-
const BODY_START_MARKER = '<!-- BUZL_TRACKING_BODY_START -->';
|
|
8
|
-
const BODY_END_MARKER = '<!-- BUZL_TRACKING_BODY_END -->';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Generate GTM & Meta Pixel head snippet
|
|
12
|
-
*/
|
|
13
|
-
function generateHeadSnippet(config) {
|
|
14
|
-
const gtmId = (config.gtmId || '').trim();
|
|
15
|
-
const metaPixelId = (config.metaPixelId || '').trim();
|
|
16
|
-
const enableDeferred = config.enableDeferred !== false;
|
|
17
|
-
|
|
18
|
-
const lines = [HEAD_START_MARKER];
|
|
19
|
-
|
|
20
|
-
// Preconnects for performance
|
|
21
|
-
if (gtmId || metaPixelId) {
|
|
22
|
-
lines.push(' <!-- Performance Preconnects for Tracking -->');
|
|
23
|
-
if (gtmId) {
|
|
24
|
-
lines.push(' <link rel="preconnect" href="https://www.googletagmanager.com" crossorigin>');
|
|
25
|
-
}
|
|
26
|
-
if (metaPixelId) {
|
|
27
|
-
lines.push(' <link rel="preconnect" href="https://connect.facebook.net" crossorigin>');
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
if (enableDeferred) {
|
|
32
|
-
lines.push(' <!-- Buzl Deferred Tracking: GTM & Meta Pixel initialized on first interaction or timeout -->');
|
|
33
|
-
lines.push(' <script>');
|
|
34
|
-
lines.push(' (function() {');
|
|
35
|
-
lines.push(' var initialized = false;');
|
|
36
|
-
lines.push(' function initTrackers() {');
|
|
37
|
-
lines.push(' if (initialized) return;');
|
|
38
|
-
lines.push(' initialized = true;');
|
|
39
|
-
lines.push(' window.removeEventListener("scroll", initTrackers);');
|
|
40
|
-
lines.push(' window.removeEventListener("mousemove", initTrackers);');
|
|
41
|
-
lines.push(' window.removeEventListener("touchstart", initTrackers);');
|
|
42
|
-
lines.push('');
|
|
43
|
-
|
|
44
|
-
if (gtmId) {
|
|
45
|
-
lines.push(' // Google Tag Manager');
|
|
46
|
-
lines.push(' (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({"gtm.start":');
|
|
47
|
-
lines.push(' new Date().getTime(),event:"gtm.js"});var f=d.getElementsByTagName(s)[0],');
|
|
48
|
-
lines.push(' j=d.createElement(s),dl=l!="dataLayer"?"&l="+l:"";j.async=true;j.src=');
|
|
49
|
-
lines.push(' "https://www.googletagmanager.com/gtm.js?id="+i+dl;f.parentNode.insertBefore(j,f);');
|
|
50
|
-
lines.push(` })(window,document,"script","dataLayer","${gtmId}");`);
|
|
51
|
-
lines.push('');
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
if (metaPixelId) {
|
|
55
|
-
lines.push(' // Meta Pixel Code');
|
|
56
|
-
lines.push(' !function(f,b,e,v,n,t,s)');
|
|
57
|
-
lines.push(' {if(f.fbq)return;n=f.fbq=function(){n.callMethod?');
|
|
58
|
-
lines.push(' n.callMethod.apply(n,arguments):n.queue.push(arguments)};');
|
|
59
|
-
lines.push(' if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version="2.0";');
|
|
60
|
-
lines.push(' n.queue=[];t=b.createElement(e);t.async=!0;');
|
|
61
|
-
lines.push(' t.src=v;s=b.getElementsByTagName(e)[0];');
|
|
62
|
-
lines.push(' s.parentNode.insertBefore(t,s)}(window, document,"script",');
|
|
63
|
-
lines.push(' "https://connect.facebook.net/en_US/fbevents.js");');
|
|
64
|
-
lines.push(` fbq("init", "${metaPixelId}");`);
|
|
65
|
-
lines.push(' fbq("track", "PageView");');
|
|
66
|
-
lines.push('');
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
lines.push(' }');
|
|
70
|
-
lines.push('');
|
|
71
|
-
lines.push(' // Debug override: trigger instantly if GTM preview / debug active');
|
|
72
|
-
lines.push(' var url = window.location.href;');
|
|
73
|
-
lines.push(' if (url.indexOf("gtm_debug=") !== -1 || url.indexOf("gtm_preview=") !== -1 || url.indexOf("gtm_auth=") !== -1) {');
|
|
74
|
-
lines.push(' initTrackers();');
|
|
75
|
-
lines.push(' } else {');
|
|
76
|
-
lines.push(' window.addEventListener("load", function() { setTimeout(initTrackers, 2000); });');
|
|
77
|
-
lines.push(' window.addEventListener("scroll", initTrackers, { passive: true });');
|
|
78
|
-
lines.push(' window.addEventListener("mousemove", initTrackers, { passive: true });');
|
|
79
|
-
lines.push(' window.addEventListener("touchstart", initTrackers, { passive: true });');
|
|
80
|
-
lines.push(' }');
|
|
81
|
-
lines.push(' })();');
|
|
82
|
-
lines.push(' </script>');
|
|
83
|
-
} else {
|
|
84
|
-
// Standard synchronous loading
|
|
85
|
-
if (gtmId) {
|
|
86
|
-
lines.push(' <!-- Google Tag Manager -->');
|
|
87
|
-
lines.push(' <script>');
|
|
88
|
-
lines.push(' (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({"gtm.start":');
|
|
89
|
-
lines.push(' new Date().getTime(),event:"gtm.js"});var f=d.getElementsByTagName(s)[0],');
|
|
90
|
-
lines.push(' j=d.createElement(s),dl=l!="dataLayer"?"&l="+l:"";j.async=true;j.src=');
|
|
91
|
-
lines.push(' "https://www.googletagmanager.com/gtm.js?id="+i+dl;f.parentNode.insertBefore(j,f);');
|
|
92
|
-
lines.push(` })(window,document,"script","dataLayer","${gtmId}");`);
|
|
93
|
-
lines.push(' </script>');
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
if (metaPixelId) {
|
|
97
|
-
lines.push(' <!-- Meta Pixel Code -->');
|
|
98
|
-
lines.push(' <script>');
|
|
99
|
-
lines.push(' !function(f,b,e,v,n,t,s)');
|
|
100
|
-
lines.push(' {if(f.fbq)return;n=f.fbq=function(){n.callMethod?');
|
|
101
|
-
lines.push(' n.callMethod.apply(n,arguments):n.queue.push(arguments)};');
|
|
102
|
-
lines.push(' if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version="2.0";');
|
|
103
|
-
lines.push(' n.queue=[];t=b.createElement(e);t.async=!0;');
|
|
104
|
-
lines.push(' t.src=v;s=b.getElementsByTagName(e)[0];');
|
|
105
|
-
lines.push(' s.parentNode.insertBefore(t,s)}(window, document,"script",');
|
|
106
|
-
lines.push(' "https://connect.facebook.net/en_US/fbevents.js");');
|
|
107
|
-
lines.push(` fbq("init", "${metaPixelId}");`);
|
|
108
|
-
lines.push(' fbq("track", "PageView");');
|
|
109
|
-
lines.push(' </script>');
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
lines.push(HEAD_END_MARKER);
|
|
114
|
-
return lines.join('\n');
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* Generate noscript tags for opening <body>
|
|
119
|
-
*/
|
|
120
|
-
function generateBodySnippet(config) {
|
|
121
|
-
const gtmId = (config.gtmId || '').trim();
|
|
122
|
-
const metaPixelId = (config.metaPixelId || '').trim();
|
|
123
|
-
|
|
124
|
-
const lines = [BODY_START_MARKER];
|
|
125
|
-
|
|
126
|
-
if (gtmId) {
|
|
127
|
-
lines.push(' <!-- Google Tag Manager (noscript) -->');
|
|
128
|
-
lines.push(` <noscript><iframe src="https://www.googletagmanager.com/ns.html?id=${gtmId}"`);
|
|
129
|
-
lines.push(' height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>');
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
if (metaPixelId) {
|
|
133
|
-
lines.push(' <!-- Meta Pixel (noscript) -->');
|
|
134
|
-
lines.push(' <noscript><img height="1" width="1" style="display:none"');
|
|
135
|
-
lines.push(` src="https://www.facebook.com/tr?id=${metaPixelId}&ev=PageView&noscript=1" /></noscript>`);
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
lines.push(BODY_END_MARKER);
|
|
139
|
-
return lines.join('\n');
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
module.exports = {
|
|
143
|
-
HEAD_START_MARKER,
|
|
144
|
-
HEAD_END_MARKER,
|
|
145
|
-
BODY_START_MARKER,
|
|
146
|
-
BODY_END_MARKER,
|
|
147
|
-
generateHeadSnippet,
|
|
148
|
-
generateBodySnippet
|
|
149
|
-
};
|
|
1
|
+
/**
|
|
2
|
+
* GTM & Meta Pixel Snippet Generators
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
const HEAD_START_MARKER = '<!-- BUZL_TRACKING_HEAD_START -->';
|
|
6
|
+
const HEAD_END_MARKER = '<!-- BUZL_TRACKING_HEAD_END -->';
|
|
7
|
+
const BODY_START_MARKER = '<!-- BUZL_TRACKING_BODY_START -->';
|
|
8
|
+
const BODY_END_MARKER = '<!-- BUZL_TRACKING_BODY_END -->';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Generate GTM & Meta Pixel head snippet
|
|
12
|
+
*/
|
|
13
|
+
function generateHeadSnippet(config) {
|
|
14
|
+
const gtmId = (config.gtmId || '').trim();
|
|
15
|
+
const metaPixelId = (config.metaPixelId || '').trim();
|
|
16
|
+
const enableDeferred = config.enableDeferred !== false;
|
|
17
|
+
|
|
18
|
+
const lines = [HEAD_START_MARKER];
|
|
19
|
+
|
|
20
|
+
// Preconnects for performance
|
|
21
|
+
if (gtmId || metaPixelId) {
|
|
22
|
+
lines.push(' <!-- Performance Preconnects for Tracking -->');
|
|
23
|
+
if (gtmId) {
|
|
24
|
+
lines.push(' <link rel="preconnect" href="https://www.googletagmanager.com" crossorigin>');
|
|
25
|
+
}
|
|
26
|
+
if (metaPixelId) {
|
|
27
|
+
lines.push(' <link rel="preconnect" href="https://connect.facebook.net" crossorigin>');
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (enableDeferred) {
|
|
32
|
+
lines.push(' <!-- Buzl Deferred Tracking: GTM & Meta Pixel initialized on first interaction or timeout -->');
|
|
33
|
+
lines.push(' <script>');
|
|
34
|
+
lines.push(' (function() {');
|
|
35
|
+
lines.push(' var initialized = false;');
|
|
36
|
+
lines.push(' function initTrackers() {');
|
|
37
|
+
lines.push(' if (initialized) return;');
|
|
38
|
+
lines.push(' initialized = true;');
|
|
39
|
+
lines.push(' window.removeEventListener("scroll", initTrackers);');
|
|
40
|
+
lines.push(' window.removeEventListener("mousemove", initTrackers);');
|
|
41
|
+
lines.push(' window.removeEventListener("touchstart", initTrackers);');
|
|
42
|
+
lines.push('');
|
|
43
|
+
|
|
44
|
+
if (gtmId) {
|
|
45
|
+
lines.push(' // Google Tag Manager');
|
|
46
|
+
lines.push(' (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({"gtm.start":');
|
|
47
|
+
lines.push(' new Date().getTime(),event:"gtm.js"});var f=d.getElementsByTagName(s)[0],');
|
|
48
|
+
lines.push(' j=d.createElement(s),dl=l!="dataLayer"?"&l="+l:"";j.async=true;j.src=');
|
|
49
|
+
lines.push(' "https://www.googletagmanager.com/gtm.js?id="+i+dl;f.parentNode.insertBefore(j,f);');
|
|
50
|
+
lines.push(` })(window,document,"script","dataLayer","${gtmId}");`);
|
|
51
|
+
lines.push('');
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (metaPixelId) {
|
|
55
|
+
lines.push(' // Meta Pixel Code');
|
|
56
|
+
lines.push(' !function(f,b,e,v,n,t,s)');
|
|
57
|
+
lines.push(' {if(f.fbq)return;n=f.fbq=function(){n.callMethod?');
|
|
58
|
+
lines.push(' n.callMethod.apply(n,arguments):n.queue.push(arguments)};');
|
|
59
|
+
lines.push(' if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version="2.0";');
|
|
60
|
+
lines.push(' n.queue=[];t=b.createElement(e);t.async=!0;');
|
|
61
|
+
lines.push(' t.src=v;s=b.getElementsByTagName(e)[0];');
|
|
62
|
+
lines.push(' s.parentNode.insertBefore(t,s)}(window, document,"script",');
|
|
63
|
+
lines.push(' "https://connect.facebook.net/en_US/fbevents.js");');
|
|
64
|
+
lines.push(` fbq("init", "${metaPixelId}");`);
|
|
65
|
+
lines.push(' fbq("track", "PageView");');
|
|
66
|
+
lines.push('');
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
lines.push(' }');
|
|
70
|
+
lines.push('');
|
|
71
|
+
lines.push(' // Debug override: trigger instantly if GTM preview / debug active');
|
|
72
|
+
lines.push(' var url = window.location.href;');
|
|
73
|
+
lines.push(' if (url.indexOf("gtm_debug=") !== -1 || url.indexOf("gtm_preview=") !== -1 || url.indexOf("gtm_auth=") !== -1) {');
|
|
74
|
+
lines.push(' initTrackers();');
|
|
75
|
+
lines.push(' } else {');
|
|
76
|
+
lines.push(' window.addEventListener("load", function() { setTimeout(initTrackers, 2000); });');
|
|
77
|
+
lines.push(' window.addEventListener("scroll", initTrackers, { passive: true });');
|
|
78
|
+
lines.push(' window.addEventListener("mousemove", initTrackers, { passive: true });');
|
|
79
|
+
lines.push(' window.addEventListener("touchstart", initTrackers, { passive: true });');
|
|
80
|
+
lines.push(' }');
|
|
81
|
+
lines.push(' })();');
|
|
82
|
+
lines.push(' </script>');
|
|
83
|
+
} else {
|
|
84
|
+
// Standard synchronous loading
|
|
85
|
+
if (gtmId) {
|
|
86
|
+
lines.push(' <!-- Google Tag Manager -->');
|
|
87
|
+
lines.push(' <script>');
|
|
88
|
+
lines.push(' (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({"gtm.start":');
|
|
89
|
+
lines.push(' new Date().getTime(),event:"gtm.js"});var f=d.getElementsByTagName(s)[0],');
|
|
90
|
+
lines.push(' j=d.createElement(s),dl=l!="dataLayer"?"&l="+l:"";j.async=true;j.src=');
|
|
91
|
+
lines.push(' "https://www.googletagmanager.com/gtm.js?id="+i+dl;f.parentNode.insertBefore(j,f);');
|
|
92
|
+
lines.push(` })(window,document,"script","dataLayer","${gtmId}");`);
|
|
93
|
+
lines.push(' </script>');
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (metaPixelId) {
|
|
97
|
+
lines.push(' <!-- Meta Pixel Code -->');
|
|
98
|
+
lines.push(' <script>');
|
|
99
|
+
lines.push(' !function(f,b,e,v,n,t,s)');
|
|
100
|
+
lines.push(' {if(f.fbq)return;n=f.fbq=function(){n.callMethod?');
|
|
101
|
+
lines.push(' n.callMethod.apply(n,arguments):n.queue.push(arguments)};');
|
|
102
|
+
lines.push(' if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version="2.0";');
|
|
103
|
+
lines.push(' n.queue=[];t=b.createElement(e);t.async=!0;');
|
|
104
|
+
lines.push(' t.src=v;s=b.getElementsByTagName(e)[0];');
|
|
105
|
+
lines.push(' s.parentNode.insertBefore(t,s)}(window, document,"script",');
|
|
106
|
+
lines.push(' "https://connect.facebook.net/en_US/fbevents.js");');
|
|
107
|
+
lines.push(` fbq("init", "${metaPixelId}");`);
|
|
108
|
+
lines.push(' fbq("track", "PageView");');
|
|
109
|
+
lines.push(' </script>');
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
lines.push(HEAD_END_MARKER);
|
|
114
|
+
return lines.join('\n');
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Generate noscript tags for opening <body>
|
|
119
|
+
*/
|
|
120
|
+
function generateBodySnippet(config) {
|
|
121
|
+
const gtmId = (config.gtmId || '').trim();
|
|
122
|
+
const metaPixelId = (config.metaPixelId || '').trim();
|
|
123
|
+
|
|
124
|
+
const lines = [BODY_START_MARKER];
|
|
125
|
+
|
|
126
|
+
if (gtmId) {
|
|
127
|
+
lines.push(' <!-- Google Tag Manager (noscript) -->');
|
|
128
|
+
lines.push(` <noscript><iframe src="https://www.googletagmanager.com/ns.html?id=${gtmId}"`);
|
|
129
|
+
lines.push(' height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>');
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
if (metaPixelId) {
|
|
133
|
+
lines.push(' <!-- Meta Pixel (noscript) -->');
|
|
134
|
+
lines.push(' <noscript><img height="1" width="1" style="display:none"');
|
|
135
|
+
lines.push(` src="https://www.facebook.com/tr?id=${metaPixelId}&ev=PageView&noscript=1" /></noscript>`);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
lines.push(BODY_END_MARKER);
|
|
139
|
+
return lines.join('\n');
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
module.exports = {
|
|
143
|
+
HEAD_START_MARKER,
|
|
144
|
+
HEAD_END_MARKER,
|
|
145
|
+
BODY_START_MARKER,
|
|
146
|
+
BODY_END_MARKER,
|
|
147
|
+
generateHeadSnippet,
|
|
148
|
+
generateBodySnippet
|
|
149
|
+
};
|