@gudhub/ssg-web-components-library 1.0.76 → 1.0.77

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gudhub/ssg-web-components-library",
3
- "version": "1.0.76",
3
+ "version": "1.0.77",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -0,0 +1,6 @@
1
+ export const GoogleTag = {
2
+ tag: 'google-tag',
3
+ category: 'Utilities',
4
+ src: '@gudhub/ssg-web-components-library/src/components/google-tag/google-tag.js',
5
+ serverOnly: false
6
+ }
@@ -0,0 +1,40 @@
1
+ class GoogleTag extends GHComponent {
2
+ constructor() {
3
+ super();
4
+ }
5
+
6
+ onClientRender() {
7
+ const timeout = parseInt(this.getAttribute('data-timeout')) || 3000;
8
+ const googleId = this.getAttribute('data-googleId');
9
+ const script = document.createElement('script');
10
+
11
+ if (!googleId) {
12
+ script.innerHTML = 'No google id for tag'
13
+ } else {
14
+ script.innerHTML = `
15
+ window.addEventListener('load', function () {
16
+ setTimeout(function () {
17
+ (function(w, d, s, l, i) {
18
+ w[l] = w[l] || [];
19
+ w[l].push({
20
+ 'gtm.start': new Date().getTime(),
21
+ event: 'gtm.js'
22
+ });
23
+ var f = d.getElementsByTagName(s)[0],
24
+ j = d.createElement(s),
25
+ dl = l != 'dataLayer' ? '&l=' + l : '';
26
+ j.async = true;
27
+ j.src = 'https://www.googletagmanager.com/gtm.js?id=' + i + dl;
28
+ f.parentNode.insertBefore(j, f);
29
+ })(window, document, 'script', 'dataLayer', '${googleId}');
30
+ }, ${timeout});
31
+ });
32
+ `;
33
+ }
34
+
35
+ document.querySelector('body').appendChild(script);
36
+ this.remove();
37
+ }
38
+ }
39
+
40
+ window.customElements.define('google-tag', GoogleTag);
package/src/config.js CHANGED
@@ -64,11 +64,9 @@ export { youtubePlayer } from './components/youtube-player/config.js';
64
64
  export { getInTouchBlockWithImage } from './components/get-in-touch-block-with-image/config.js';
65
65
  export { PageBannerImageAndMenu } from './components/page-banner-image-and-menu/config.js';
66
66
  export { GoogleAnalytics } from './components/google-analytics/config.js';
67
+ export { GoogleTag } from './components/google-tag/config.js';
67
68
  export { cookiesPopup } from './components/cookies-popup/config.js';
68
69
 
69
-
70
-
71
-
72
70
  // export { liqPayComponent } from './components/liqpay-component/config.js';
73
71
  // export { htmlTextFromEditorJs } from './components/html-text-from-editor-js/config.js';
74
72
  // export { toggleReadMoreButtonComponent } from './components/html-text-from-editor-js/toggle-read-more-button-component/config.js';