@mindful-web/marko-web-gtm 1.0.0
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/.eslintignore +1 -0
- package/LICENSE +21 -0
- package/README.md +65 -0
- package/browser/.eslintrc.js +1 -0
- package/browser/index.js +14 -0
- package/browser/track-bus-event.vue +61 -0
- package/browser/track-in-view-event.vue +45 -0
- package/browser/track-load-more.vue +25 -0
- package/components/context/content.marko +97 -0
- package/components/context/content.marko.js +144 -0
- package/components/context/default.marko +9 -0
- package/components/context/default.marko.js +41 -0
- package/components/context/dynamic-page.marko +28 -0
- package/components/context/dynamic-page.marko.js +75 -0
- package/components/context/magazine-issue.marko +30 -0
- package/components/context/magazine-issue.marko.js +77 -0
- package/components/context/magazine-publication.marko +25 -0
- package/components/context/magazine-publication.marko.js +72 -0
- package/components/context/marko.json +44 -0
- package/components/context/native-x-story.marko +9 -0
- package/components/context/native-x-story.marko.js +41 -0
- package/components/context/website-section.marko +32 -0
- package/components/context/website-section.marko.js +79 -0
- package/components/init.marko +52 -0
- package/components/init.marko.js +104 -0
- package/components/marko.json +61 -0
- package/components/noscript.marko +11 -0
- package/components/noscript.marko.js +44 -0
- package/components/push.marko +7 -0
- package/components/push.marko.js +35 -0
- package/components/slot.marko +9 -0
- package/components/slot.marko.js +40 -0
- package/components/start.marko +7 -0
- package/components/start.marko.js +37 -0
- package/components/track-bus-event.marko +1 -0
- package/components/track-bus-event.marko.js +30 -0
- package/components/track-inview-event.marko +1 -0
- package/components/track-inview-event.marko.js +30 -0
- package/components/track-load-more.marko +1 -0
- package/components/track-load-more.marko.js +30 -0
- package/context/content.js +74 -0
- package/context/default.js +11 -0
- package/context/dynamic-page.js +17 -0
- package/context/index.js +17 -0
- package/context/magazine-issue.js +22 -0
- package/context/magazine-publication.js +15 -0
- package/context/native-x-story.js +37 -0
- package/context/website-section.js +24 -0
- package/marko.json +6 -0
- package/package.json +31 -0
- package/scss/slot.scss +7 -0
- package/utils/build-query-string.js +3 -0
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
// Compiled using marko@4.20.2 - DO NOT EDIT
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
var marko_template = module.exports = require("marko/dist/html").t(__filename),
|
|
5
|
+
marko_componentType = "/@mindful-web/marko-web-gtm$1.0.0/components/context/magazine-issue.marko",
|
|
6
|
+
marko_component = require("./magazine-issue.marko"),
|
|
7
|
+
marko_renderer = require("marko/dist/runtime/components/renderer"),
|
|
8
|
+
module_gql = require("graphql-tag"),
|
|
9
|
+
gql = module_gql.default || module_gql,
|
|
10
|
+
module_utils_module = require("@mindful-web/utils"),
|
|
11
|
+
utils_module = module_utils_module.default || module_utils_module,
|
|
12
|
+
isFunction = module_utils_module.isFunction,
|
|
13
|
+
warn = module_utils_module.warn,
|
|
14
|
+
module_context_module = require("../../context"),
|
|
15
|
+
context_module = module_context_module.default || module_context_module,
|
|
16
|
+
magazineIssueBuilder = module_context_module.magazineIssueBuilder,
|
|
17
|
+
marko_dynamicTag = require("marko/dist/runtime/helpers/dynamic-tag"),
|
|
18
|
+
marko_web_query_template = require("@mindful-web/marko-core/components/queries/index.marko"),
|
|
19
|
+
marko_loadTag = require("marko/dist/runtime/helpers/load-tag"),
|
|
20
|
+
marko_web_query_tag = marko_loadTag(marko_web_query_template);
|
|
21
|
+
|
|
22
|
+
function render(input, out, __component, component, state) {
|
|
23
|
+
var data = input;
|
|
24
|
+
|
|
25
|
+
const { req } = out.global;
|
|
26
|
+
|
|
27
|
+
const { id } = input;
|
|
28
|
+
|
|
29
|
+
const builder = isFunction(input.builder) ? input.builder : magazineIssueBuilder;
|
|
30
|
+
|
|
31
|
+
const queryFragment = input.queryFragment || gql`
|
|
32
|
+
fragment MagazineIssueContextFragment on MagazineIssue {
|
|
33
|
+
id
|
|
34
|
+
name
|
|
35
|
+
canonicalPath
|
|
36
|
+
mailed
|
|
37
|
+
publication {
|
|
38
|
+
id
|
|
39
|
+
name
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
`;
|
|
43
|
+
|
|
44
|
+
if (id) {
|
|
45
|
+
marko_web_query_tag({
|
|
46
|
+
collapsible: true,
|
|
47
|
+
name: "magazine-issue",
|
|
48
|
+
params: {
|
|
49
|
+
id: id,
|
|
50
|
+
queryFragment: queryFragment
|
|
51
|
+
},
|
|
52
|
+
renderBody: function(out, { node }) {
|
|
53
|
+
const context = builder({ type: "magazine-issue", obj: node, req });
|
|
54
|
+
|
|
55
|
+
marko_dynamicTag(out, input.renderBody, function() {
|
|
56
|
+
return {
|
|
57
|
+
context: context
|
|
58
|
+
};
|
|
59
|
+
}, null, null, null, __component, "1");
|
|
60
|
+
}
|
|
61
|
+
}, out, __component, "0");
|
|
62
|
+
} else {
|
|
63
|
+
warn('Unable to create GTM magazine issue context: no issue id was provided.');
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
marko_template._ = marko_renderer(render, {
|
|
68
|
+
e_: marko_componentType
|
|
69
|
+
}, marko_component);
|
|
70
|
+
|
|
71
|
+
marko_template.meta = {
|
|
72
|
+
id: "/@mindful-web/marko-web-gtm$1.0.0/components/context/magazine-issue.marko",
|
|
73
|
+
component: "./magazine-issue.marko",
|
|
74
|
+
tags: [
|
|
75
|
+
"@mindful-web/marko-core/components/queries/index.marko"
|
|
76
|
+
]
|
|
77
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import gql from "graphql-tag";
|
|
2
|
+
import { isFunction, warn } from "@mindful-web/utils";
|
|
3
|
+
import { magazinePublicationBuilder } from "../../context";
|
|
4
|
+
|
|
5
|
+
$ const { req } = out.global;
|
|
6
|
+
$ const { id } = input;
|
|
7
|
+
$ const builder = isFunction(input.builder) ? input.builder : magazinePublicationBuilder;
|
|
8
|
+
|
|
9
|
+
$ const queryFragment = input.queryFragment || gql`
|
|
10
|
+
fragment MagazinePublicationContextFragment on MagazinePublication {
|
|
11
|
+
id
|
|
12
|
+
name
|
|
13
|
+
canonicalPath
|
|
14
|
+
}
|
|
15
|
+
`;
|
|
16
|
+
|
|
17
|
+
<if(id)>
|
|
18
|
+
<marko-web-query|{ node }| name="magazine-publication" params={ id, queryFragment }>
|
|
19
|
+
$ const context = builder({ type: "magazine-publication", obj: node, req });
|
|
20
|
+
<${input.renderBody} context=context />
|
|
21
|
+
</marko-web-query>
|
|
22
|
+
</if>
|
|
23
|
+
<else>
|
|
24
|
+
$ warn('Unable to create GTM magazine publication context: no publication id was provided.');
|
|
25
|
+
</else>
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// Compiled using marko@4.20.2 - DO NOT EDIT
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
var marko_template = module.exports = require("marko/dist/html").t(__filename),
|
|
5
|
+
marko_componentType = "/@mindful-web/marko-web-gtm$1.0.0/components/context/magazine-publication.marko",
|
|
6
|
+
marko_component = require("./magazine-publication.marko"),
|
|
7
|
+
marko_renderer = require("marko/dist/runtime/components/renderer"),
|
|
8
|
+
module_gql = require("graphql-tag"),
|
|
9
|
+
gql = module_gql.default || module_gql,
|
|
10
|
+
module_utils_module = require("@mindful-web/utils"),
|
|
11
|
+
utils_module = module_utils_module.default || module_utils_module,
|
|
12
|
+
isFunction = module_utils_module.isFunction,
|
|
13
|
+
warn = module_utils_module.warn,
|
|
14
|
+
module_context_module = require("../../context"),
|
|
15
|
+
context_module = module_context_module.default || module_context_module,
|
|
16
|
+
magazinePublicationBuilder = module_context_module.magazinePublicationBuilder,
|
|
17
|
+
marko_dynamicTag = require("marko/dist/runtime/helpers/dynamic-tag"),
|
|
18
|
+
marko_web_query_template = require("@mindful-web/marko-core/components/queries/index.marko"),
|
|
19
|
+
marko_loadTag = require("marko/dist/runtime/helpers/load-tag"),
|
|
20
|
+
marko_web_query_tag = marko_loadTag(marko_web_query_template);
|
|
21
|
+
|
|
22
|
+
function render(input, out, __component, component, state) {
|
|
23
|
+
var data = input;
|
|
24
|
+
|
|
25
|
+
const { req } = out.global;
|
|
26
|
+
|
|
27
|
+
const { id } = input;
|
|
28
|
+
|
|
29
|
+
const builder = isFunction(input.builder) ? input.builder : magazinePublicationBuilder;
|
|
30
|
+
|
|
31
|
+
const queryFragment = input.queryFragment || gql`
|
|
32
|
+
fragment MagazinePublicationContextFragment on MagazinePublication {
|
|
33
|
+
id
|
|
34
|
+
name
|
|
35
|
+
canonicalPath
|
|
36
|
+
}
|
|
37
|
+
`;
|
|
38
|
+
|
|
39
|
+
if (id) {
|
|
40
|
+
marko_web_query_tag({
|
|
41
|
+
collapsible: true,
|
|
42
|
+
name: "magazine-publication",
|
|
43
|
+
params: {
|
|
44
|
+
id: id,
|
|
45
|
+
queryFragment: queryFragment
|
|
46
|
+
},
|
|
47
|
+
renderBody: function(out, { node }) {
|
|
48
|
+
const context = builder({ type: "magazine-publication", obj: node, req });
|
|
49
|
+
|
|
50
|
+
marko_dynamicTag(out, input.renderBody, function() {
|
|
51
|
+
return {
|
|
52
|
+
context: context
|
|
53
|
+
};
|
|
54
|
+
}, null, null, null, __component, "1");
|
|
55
|
+
}
|
|
56
|
+
}, out, __component, "0");
|
|
57
|
+
} else {
|
|
58
|
+
warn('Unable to create GTM magazine publication context: no publication id was provided.');
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
marko_template._ = marko_renderer(render, {
|
|
63
|
+
e_: marko_componentType
|
|
64
|
+
}, marko_component);
|
|
65
|
+
|
|
66
|
+
marko_template.meta = {
|
|
67
|
+
id: "/@mindful-web/marko-web-gtm$1.0.0/components/context/magazine-publication.marko",
|
|
68
|
+
component: "./magazine-publication.marko",
|
|
69
|
+
tags: [
|
|
70
|
+
"@mindful-web/marko-core/components/queries/index.marko"
|
|
71
|
+
]
|
|
72
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"<marko-web-gtm-default-context>": {
|
|
3
|
+
"template": "./default.marko",
|
|
4
|
+
"@type": "string",
|
|
5
|
+
"@obj": "object",
|
|
6
|
+
"@builder": "function"
|
|
7
|
+
},
|
|
8
|
+
"<marko-web-gtm-content-context>": {
|
|
9
|
+
"template": "./content.marko",
|
|
10
|
+
"@id": "number",
|
|
11
|
+
"@builder": "function",
|
|
12
|
+
"@query-fragment": "expression"
|
|
13
|
+
},
|
|
14
|
+
"<marko-web-gtm-website-section-context>": {
|
|
15
|
+
"template": "./website-section.marko",
|
|
16
|
+
"@alias": "string",
|
|
17
|
+
"@builder": "function",
|
|
18
|
+
"@query-fragment": "expression"
|
|
19
|
+
},
|
|
20
|
+
"<marko-web-gtm-dynamic-page-context>": {
|
|
21
|
+
"template": "./dynamic-page.marko",
|
|
22
|
+
"@alias": "string",
|
|
23
|
+
"@builder": "function",
|
|
24
|
+
"@query-fragment": "expression"
|
|
25
|
+
},
|
|
26
|
+
"<marko-web-gtm-magazine-issue-context>": {
|
|
27
|
+
"template": "./magazine-issue.marko",
|
|
28
|
+
"@id": "string",
|
|
29
|
+
"@builder": "function",
|
|
30
|
+
"@query-fragment": "expression"
|
|
31
|
+
},
|
|
32
|
+
"<marko-web-gtm-magazine-publication-context>": {
|
|
33
|
+
"template": "./magazine-publication.marko",
|
|
34
|
+
"@id": "string",
|
|
35
|
+
"@builder": "function",
|
|
36
|
+
"@query-fragment": "expression"
|
|
37
|
+
},
|
|
38
|
+
"<marko-web-gtm-native-x-story-context>": {
|
|
39
|
+
"template": "./native-x-story.marko",
|
|
40
|
+
"@type": "string",
|
|
41
|
+
"@obj": "object",
|
|
42
|
+
"@builder": "function"
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { isFunction, warn } from "@mindful-web/utils";
|
|
2
|
+
import { nativeXStoryBuilder } from "../../context";
|
|
3
|
+
|
|
4
|
+
$ const { req } = out.global;
|
|
5
|
+
$ const builder = isFunction(input.builder) ? input.builder : nativeXStoryBuilder;
|
|
6
|
+
$ const type = input.type || "content";
|
|
7
|
+
|
|
8
|
+
$ const context = builder({ type, obj: input.obj, req });
|
|
9
|
+
<${input.renderBody} context=context />
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// Compiled using marko@4.20.2 - DO NOT EDIT
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
var marko_template = module.exports = require("marko/dist/html").t(__filename),
|
|
5
|
+
marko_componentType = "/@mindful-web/marko-web-gtm$1.0.0/components/context/native-x-story.marko",
|
|
6
|
+
marko_renderer = require("marko/dist/runtime/components/renderer"),
|
|
7
|
+
module_utils_module = require("@mindful-web/utils"),
|
|
8
|
+
utils_module = module_utils_module.default || module_utils_module,
|
|
9
|
+
isFunction = module_utils_module.isFunction,
|
|
10
|
+
warn = module_utils_module.warn,
|
|
11
|
+
module_context_module = require("../../context"),
|
|
12
|
+
context_module = module_context_module.default || module_context_module,
|
|
13
|
+
nativeXStoryBuilder = module_context_module.nativeXStoryBuilder,
|
|
14
|
+
marko_dynamicTag = require("marko/dist/runtime/helpers/dynamic-tag");
|
|
15
|
+
|
|
16
|
+
function render(input, out, __component, component, state) {
|
|
17
|
+
var data = input;
|
|
18
|
+
|
|
19
|
+
const { req } = out.global;
|
|
20
|
+
|
|
21
|
+
const builder = isFunction(input.builder) ? input.builder : nativeXStoryBuilder;
|
|
22
|
+
|
|
23
|
+
const type = input.type || "content";
|
|
24
|
+
|
|
25
|
+
const context = builder({ type, obj: input.obj, req });
|
|
26
|
+
|
|
27
|
+
marko_dynamicTag(out, input.renderBody, function() {
|
|
28
|
+
return {
|
|
29
|
+
context: context
|
|
30
|
+
};
|
|
31
|
+
}, null, null, null, __component, "0");
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
marko_template._ = marko_renderer(render, {
|
|
35
|
+
d_: true,
|
|
36
|
+
e_: marko_componentType
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
marko_template.meta = {
|
|
40
|
+
id: "/@mindful-web/marko-web-gtm$1.0.0/components/context/native-x-story.marko"
|
|
41
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import gql from "graphql-tag";
|
|
2
|
+
import { isFunction, warn } from "@mindful-web/utils";
|
|
3
|
+
import { websiteSectionBuilder } from "../../context";
|
|
4
|
+
|
|
5
|
+
$ const { req } = out.global;
|
|
6
|
+
$ const { alias } = input;
|
|
7
|
+
$ const builder = isFunction(input.builder) ? input.builder : websiteSectionBuilder;
|
|
8
|
+
|
|
9
|
+
$ const queryFragment = input.queryFragment || gql`
|
|
10
|
+
fragment WebsiteSectionContextFragment on WebsiteSection {
|
|
11
|
+
id
|
|
12
|
+
alias
|
|
13
|
+
name
|
|
14
|
+
fullName
|
|
15
|
+
canonicalPath
|
|
16
|
+
hierarchy {
|
|
17
|
+
id
|
|
18
|
+
name
|
|
19
|
+
alias
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
`;
|
|
23
|
+
|
|
24
|
+
<if(alias)>
|
|
25
|
+
<marko-web-query|{ node }| name="website-section" params={ alias, queryFragment }>
|
|
26
|
+
$ const context = builder({ type: "website-section", obj: node, req });
|
|
27
|
+
<${input.renderBody} context=context />
|
|
28
|
+
</marko-web-query>
|
|
29
|
+
</if>
|
|
30
|
+
<else>
|
|
31
|
+
$ warn('Unable to create GTM website section context: no section alias was provided.');
|
|
32
|
+
</else>
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
// Compiled using marko@4.20.2 - DO NOT EDIT
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
var marko_template = module.exports = require("marko/dist/html").t(__filename),
|
|
5
|
+
marko_componentType = "/@mindful-web/marko-web-gtm$1.0.0/components/context/website-section.marko",
|
|
6
|
+
marko_component = require("./website-section.marko"),
|
|
7
|
+
marko_renderer = require("marko/dist/runtime/components/renderer"),
|
|
8
|
+
module_gql = require("graphql-tag"),
|
|
9
|
+
gql = module_gql.default || module_gql,
|
|
10
|
+
module_utils_module = require("@mindful-web/utils"),
|
|
11
|
+
utils_module = module_utils_module.default || module_utils_module,
|
|
12
|
+
isFunction = module_utils_module.isFunction,
|
|
13
|
+
warn = module_utils_module.warn,
|
|
14
|
+
module_context_module = require("../../context"),
|
|
15
|
+
context_module = module_context_module.default || module_context_module,
|
|
16
|
+
websiteSectionBuilder = module_context_module.websiteSectionBuilder,
|
|
17
|
+
marko_dynamicTag = require("marko/dist/runtime/helpers/dynamic-tag"),
|
|
18
|
+
marko_web_query_template = require("@mindful-web/marko-core/components/queries/index.marko"),
|
|
19
|
+
marko_loadTag = require("marko/dist/runtime/helpers/load-tag"),
|
|
20
|
+
marko_web_query_tag = marko_loadTag(marko_web_query_template);
|
|
21
|
+
|
|
22
|
+
function render(input, out, __component, component, state) {
|
|
23
|
+
var data = input;
|
|
24
|
+
|
|
25
|
+
const { req } = out.global;
|
|
26
|
+
|
|
27
|
+
const { alias } = input;
|
|
28
|
+
|
|
29
|
+
const builder = isFunction(input.builder) ? input.builder : websiteSectionBuilder;
|
|
30
|
+
|
|
31
|
+
const queryFragment = input.queryFragment || gql`
|
|
32
|
+
fragment WebsiteSectionContextFragment on WebsiteSection {
|
|
33
|
+
id
|
|
34
|
+
alias
|
|
35
|
+
name
|
|
36
|
+
fullName
|
|
37
|
+
canonicalPath
|
|
38
|
+
hierarchy {
|
|
39
|
+
id
|
|
40
|
+
name
|
|
41
|
+
alias
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
`;
|
|
45
|
+
|
|
46
|
+
if (alias) {
|
|
47
|
+
marko_web_query_tag({
|
|
48
|
+
collapsible: true,
|
|
49
|
+
name: "website-section",
|
|
50
|
+
params: {
|
|
51
|
+
alias: alias,
|
|
52
|
+
queryFragment: queryFragment
|
|
53
|
+
},
|
|
54
|
+
renderBody: function(out, { node }) {
|
|
55
|
+
const context = builder({ type: "website-section", obj: node, req });
|
|
56
|
+
|
|
57
|
+
marko_dynamicTag(out, input.renderBody, function() {
|
|
58
|
+
return {
|
|
59
|
+
context: context
|
|
60
|
+
};
|
|
61
|
+
}, null, null, null, __component, "1");
|
|
62
|
+
}
|
|
63
|
+
}, out, __component, "0");
|
|
64
|
+
} else {
|
|
65
|
+
warn('Unable to create GTM website section context: no section alias was provided.');
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
marko_template._ = marko_renderer(render, {
|
|
70
|
+
e_: marko_componentType
|
|
71
|
+
}, marko_component);
|
|
72
|
+
|
|
73
|
+
marko_template.meta = {
|
|
74
|
+
id: "/@mindful-web/marko-web-gtm$1.0.0/components/context/website-section.marko",
|
|
75
|
+
component: "./website-section.marko",
|
|
76
|
+
tags: [
|
|
77
|
+
"@mindful-web/marko-core/components/queries/index.marko"
|
|
78
|
+
]
|
|
79
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { isObject, warn } from "@mindful-web/utils";
|
|
2
|
+
|
|
3
|
+
$ const disabledFeatures = out.global.disabledFeatures || new Set();
|
|
4
|
+
|
|
5
|
+
$ const { isArray } = Array;
|
|
6
|
+
|
|
7
|
+
$ const createContainerScript = (containerId, name) => `
|
|
8
|
+
(function(w,d,s,l,i){w[l]=w[l]||[];
|
|
9
|
+
var f=d.getElementsByTagName(s)[0],
|
|
10
|
+
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
|
|
11
|
+
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
|
|
12
|
+
})(window,document,'script','${name}','${containerId}');
|
|
13
|
+
`;
|
|
14
|
+
|
|
15
|
+
$ const on = disabledFeatures.has('gtm') ? 'never' : input.on;
|
|
16
|
+
$ const name = input.name || "dataLayer";
|
|
17
|
+
$ const containerIds = (isArray(input.containerId) ? input.containerId : [input.containerId]).filter(v => v);
|
|
18
|
+
$ const start = input.start == null ? false : input.start;
|
|
19
|
+
|
|
20
|
+
<if(on && containerIds.length)>
|
|
21
|
+
<for|containerId| of=containerIds>
|
|
22
|
+
$ let src = `https://www.googletagmanager.com/gtm.js?id=${containerId}`;
|
|
23
|
+
$ if (name !== "dataLayer") src = `${src}&l=${name}`;
|
|
24
|
+
<marko-web-deferred-script-loader-register
|
|
25
|
+
name=`${name}_${containerId}`
|
|
26
|
+
src=src
|
|
27
|
+
on=on
|
|
28
|
+
request-frame=input.requestFrame
|
|
29
|
+
target-tag=input.targetTag
|
|
30
|
+
init=`var w = window, l = '${name}'; w[l] = w[l] || [];`
|
|
31
|
+
init-only=input.initOnly
|
|
32
|
+
/>
|
|
33
|
+
</for>
|
|
34
|
+
</if>
|
|
35
|
+
<else-if(containerIds.length)>
|
|
36
|
+
$ const scripts = containerIds.map(containerId => createContainerScript(containerId, name));
|
|
37
|
+
<script>${scripts.join().replace(/\n/g, '')}</script>
|
|
38
|
+
</else-if>
|
|
39
|
+
|
|
40
|
+
<if(containerIds.length)>
|
|
41
|
+
<if(input.push)>
|
|
42
|
+
<!-- Immediately push data to the container -->
|
|
43
|
+
<marko-web-gtm-push name=name data=input.push />
|
|
44
|
+
</if>
|
|
45
|
+
<if(start)>
|
|
46
|
+
<!-- Immediately start the container -->
|
|
47
|
+
<marko-web-gtm-start name=name />
|
|
48
|
+
</if>
|
|
49
|
+
</if>
|
|
50
|
+
<else>
|
|
51
|
+
$ warn('Unable to create GTM container script: no container IDs were provided.');
|
|
52
|
+
</else>
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
// Compiled using marko@4.20.2 - DO NOT EDIT
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
var marko_template = module.exports = require("marko/dist/html").t(__filename),
|
|
5
|
+
marko_componentType = "/@mindful-web/marko-web-gtm$1.0.0/components/init.marko",
|
|
6
|
+
marko_renderer = require("marko/dist/runtime/components/renderer"),
|
|
7
|
+
module_utils_module = require("@mindful-web/utils"),
|
|
8
|
+
utils_module = module_utils_module.default || module_utils_module,
|
|
9
|
+
isObject = module_utils_module.isObject,
|
|
10
|
+
warn = module_utils_module.warn,
|
|
11
|
+
marko_forOf = require("marko/dist/runtime/helpers/for-of"),
|
|
12
|
+
marko_web_deferred_script_loader_register_template = require("@mindful-web/marko-web-deferred-script-loader/components/register.marko"),
|
|
13
|
+
marko_loadTag = require("marko/dist/runtime/helpers/load-tag"),
|
|
14
|
+
marko_web_deferred_script_loader_register_tag = marko_loadTag(marko_web_deferred_script_loader_register_template),
|
|
15
|
+
helpers_escape_xml = require("marko/dist/runtime/html/helpers/escape-xml"),
|
|
16
|
+
marko_escapeXml = helpers_escape_xml.x,
|
|
17
|
+
marko_escapeScript = require("marko/dist/runtime/html/helpers/escape-script-placeholder"),
|
|
18
|
+
marko_web_gtm_push_template = require("./push.marko"),
|
|
19
|
+
marko_web_gtm_push_tag = marko_loadTag(marko_web_gtm_push_template),
|
|
20
|
+
marko_web_gtm_start_template = require("./start.marko"),
|
|
21
|
+
marko_web_gtm_start_tag = marko_loadTag(marko_web_gtm_start_template);
|
|
22
|
+
|
|
23
|
+
function render(input, out, __component, component, state) {
|
|
24
|
+
var data = input;
|
|
25
|
+
|
|
26
|
+
const disabledFeatures = out.global.disabledFeatures || new Set();
|
|
27
|
+
|
|
28
|
+
const { isArray } = Array;
|
|
29
|
+
|
|
30
|
+
const createContainerScript = (containerId, name) => `
|
|
31
|
+
(function(w,d,s,l,i){w[l]=w[l]||[];
|
|
32
|
+
var f=d.getElementsByTagName(s)[0],
|
|
33
|
+
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
|
|
34
|
+
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
|
|
35
|
+
})(window,document,'script','${name}','${containerId}');
|
|
36
|
+
`;
|
|
37
|
+
|
|
38
|
+
const on = disabledFeatures.has('gtm') ? 'never' : input.on;
|
|
39
|
+
|
|
40
|
+
const name = input.name || "dataLayer";
|
|
41
|
+
|
|
42
|
+
const containerIds = (isArray(input.containerId) ? input.containerId : [input.containerId]).filter(v => v);
|
|
43
|
+
|
|
44
|
+
const start = input.start == null ? false : input.start;
|
|
45
|
+
|
|
46
|
+
if (on && containerIds.length) {
|
|
47
|
+
var $for$0 = 0;
|
|
48
|
+
|
|
49
|
+
marko_forOf(containerIds, function(containerId) {
|
|
50
|
+
let src = `https://www.googletagmanager.com/gtm.js?id=${containerId}`;
|
|
51
|
+
|
|
52
|
+
if (name !== "dataLayer") src = `${src}&l=${name}`;
|
|
53
|
+
|
|
54
|
+
var $keyScope$0 = "[" + (($for$0++) + "]");
|
|
55
|
+
|
|
56
|
+
marko_web_deferred_script_loader_register_tag({
|
|
57
|
+
name: (name + "_") + containerId,
|
|
58
|
+
src: src,
|
|
59
|
+
on: on,
|
|
60
|
+
requestFrame: input.requestFrame,
|
|
61
|
+
targetTag: input.targetTag,
|
|
62
|
+
init: ("var w = window, l = '" + name) + "'; w[l] = w[l] || [];",
|
|
63
|
+
initOnly: input.initOnly
|
|
64
|
+
}, out, __component, "0" + $keyScope$0);
|
|
65
|
+
});
|
|
66
|
+
} else if (containerIds.length) {
|
|
67
|
+
const scripts = containerIds.map(containerId => createContainerScript(containerId, name));
|
|
68
|
+
|
|
69
|
+
out.w("<script>" +
|
|
70
|
+
marko_escapeScript(scripts.join().replace(/\n/g, "")) +
|
|
71
|
+
"</script>");
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (containerIds.length) {
|
|
75
|
+
if (input.push) {
|
|
76
|
+
marko_web_gtm_push_tag({
|
|
77
|
+
name: name,
|
|
78
|
+
data: input.push
|
|
79
|
+
}, out, __component, "1");
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (start) {
|
|
83
|
+
marko_web_gtm_start_tag({
|
|
84
|
+
name: name
|
|
85
|
+
}, out, __component, "2");
|
|
86
|
+
}
|
|
87
|
+
} else {
|
|
88
|
+
warn('Unable to create GTM container script: no container IDs were provided.');
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
marko_template._ = marko_renderer(render, {
|
|
93
|
+
d_: true,
|
|
94
|
+
e_: marko_componentType
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
marko_template.meta = {
|
|
98
|
+
id: "/@mindful-web/marko-web-gtm$1.0.0/components/init.marko",
|
|
99
|
+
tags: [
|
|
100
|
+
"@mindful-web/marko-web-deferred-script-loader/components/register.marko",
|
|
101
|
+
"./push.marko",
|
|
102
|
+
"./start.marko"
|
|
103
|
+
]
|
|
104
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"taglib-imports": [
|
|
3
|
+
"./context/marko.json"
|
|
4
|
+
],
|
|
5
|
+
"<marko-web-gtm-init>": {
|
|
6
|
+
"template": "./init.marko",
|
|
7
|
+
"@container-id": "expression",
|
|
8
|
+
"@name": {
|
|
9
|
+
"type": "string",
|
|
10
|
+
"default-value": "dataLayer"
|
|
11
|
+
},
|
|
12
|
+
"@push": "object",
|
|
13
|
+
"@start": {
|
|
14
|
+
"type": "boolean",
|
|
15
|
+
"default-value": false
|
|
16
|
+
},
|
|
17
|
+
"@on": "string",
|
|
18
|
+
"@target-tag": "string",
|
|
19
|
+
"@request-frame": "boolean",
|
|
20
|
+
"@init-only": "boolean"
|
|
21
|
+
},
|
|
22
|
+
"<marko-web-gtm-start>": {
|
|
23
|
+
"template": "./start.marko",
|
|
24
|
+
"@name": {
|
|
25
|
+
"type": "string",
|
|
26
|
+
"default-value": "dataLayer"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"<marko-web-gtm-noscript>": {
|
|
30
|
+
"template": "./noscript.marko",
|
|
31
|
+
"@container-id": "expression"
|
|
32
|
+
},
|
|
33
|
+
"<marko-web-gtm-push>": {
|
|
34
|
+
"template": "./push.marko",
|
|
35
|
+
"@name": {
|
|
36
|
+
"type": "string",
|
|
37
|
+
"default-value": "dataLayer"
|
|
38
|
+
},
|
|
39
|
+
"@data": "object"
|
|
40
|
+
},
|
|
41
|
+
"<marko-web-gtm-slot>": {
|
|
42
|
+
"template": "./slot.marko",
|
|
43
|
+
"@prefix": "string",
|
|
44
|
+
"@name": "string",
|
|
45
|
+
"@class": "string",
|
|
46
|
+
"@modifiers": "array"
|
|
47
|
+
},
|
|
48
|
+
"<marko-web-gtm-track-inview-event>": {
|
|
49
|
+
"template": "./track-inview-event.marko"
|
|
50
|
+
},
|
|
51
|
+
"<marko-web-gtm-track-load-more>": {
|
|
52
|
+
"template": "./track-load-more.marko"
|
|
53
|
+
},
|
|
54
|
+
"<marko-web-gtm-track-bus-event>": {
|
|
55
|
+
"template": "./track-bus-event.marko",
|
|
56
|
+
"@on": "string",
|
|
57
|
+
"@event-name": "string",
|
|
58
|
+
"@layer-name": "string",
|
|
59
|
+
"@clear-data": "boolean"
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
$ const { isArray } = Array;
|
|
2
|
+
$ const containerIds = (isArray(input.containerId) ? input.containerId : [input.containerId]).filter(v => v);
|
|
3
|
+
|
|
4
|
+
<if(containerIds.length)>
|
|
5
|
+
<for|containerId| of=containerIds>
|
|
6
|
+
<!-- Google Tag Manager (noscript) -->
|
|
7
|
+
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id={{ containerId }}"
|
|
8
|
+
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
|
|
9
|
+
<!-- End Google Tag Manager (noscript) -->
|
|
10
|
+
</for>
|
|
11
|
+
</if>
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// Compiled using marko@4.20.2 - DO NOT EDIT
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
var marko_template = module.exports = require("marko/dist/html").t(__filename),
|
|
5
|
+
marko_componentType = "/@mindful-web/marko-web-gtm$1.0.0/components/noscript.marko",
|
|
6
|
+
marko_renderer = require("marko/dist/runtime/components/renderer"),
|
|
7
|
+
marko_forOf = require("marko/dist/runtime/helpers/for-of"),
|
|
8
|
+
noscript_template = require("./noscript.marko"),
|
|
9
|
+
marko_loadTag = require("marko/dist/runtime/helpers/load-tag"),
|
|
10
|
+
noscript_tag = marko_loadTag(noscript_template);
|
|
11
|
+
|
|
12
|
+
function render(input, out, __component, component, state) {
|
|
13
|
+
var data = input;
|
|
14
|
+
|
|
15
|
+
const { isArray } = Array;
|
|
16
|
+
|
|
17
|
+
const containerIds = (isArray(input.containerId) ? input.containerId : [input.containerId]).filter(v => v);
|
|
18
|
+
|
|
19
|
+
if (containerIds.length) {
|
|
20
|
+
var $for$0 = 0;
|
|
21
|
+
|
|
22
|
+
marko_forOf(containerIds, function(containerId) {
|
|
23
|
+
var $keyScope$0 = "[" + (($for$0++) + "]");
|
|
24
|
+
|
|
25
|
+
noscript_tag({
|
|
26
|
+
renderBody: function(out) {
|
|
27
|
+
out.w("<iframe src=\"https://www.googletagmanager.com/ns.html?id={{ containerId }}\" height=\"0\" width=\"0\" style=\"display:none;visibility:hidden\"></iframe>");
|
|
28
|
+
}
|
|
29
|
+
}, out, __component, "0" + $keyScope$0);
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
marko_template._ = marko_renderer(render, {
|
|
35
|
+
d_: true,
|
|
36
|
+
e_: marko_componentType
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
marko_template.meta = {
|
|
40
|
+
id: "/@mindful-web/marko-web-gtm$1.0.0/components/noscript.marko",
|
|
41
|
+
tags: [
|
|
42
|
+
"./noscript.marko"
|
|
43
|
+
]
|
|
44
|
+
};
|