@segment/analytics-browser-actions-google-campaign-manager 1.1.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.
Files changed (55) hide show
  1. package/README.md +31 -0
  2. package/dist/cjs/counterActivity/generated-types.d.ts +13 -0
  3. package/dist/cjs/counterActivity/generated-types.js +3 -0
  4. package/dist/cjs/counterActivity/generated-types.js.map +1 -0
  5. package/dist/cjs/counterActivity/index.d.ts +5 -0
  6. package/dist/cjs/counterActivity/index.js +68 -0
  7. package/dist/cjs/counterActivity/index.js.map +1 -0
  8. package/dist/cjs/generated-types.d.ts +5 -0
  9. package/dist/cjs/generated-types.js +3 -0
  10. package/dist/cjs/generated-types.js.map +1 -0
  11. package/dist/cjs/index.d.ts +11 -0
  12. package/dist/cjs/index.js +55 -0
  13. package/dist/cjs/index.js.map +1 -0
  14. package/dist/cjs/salesActivity/generated-types.d.ts +15 -0
  15. package/dist/cjs/salesActivity/generated-types.js +3 -0
  16. package/dist/cjs/salesActivity/generated-types.js.map +1 -0
  17. package/dist/cjs/salesActivity/index.d.ts +5 -0
  18. package/dist/cjs/salesActivity/index.js +90 -0
  19. package/dist/cjs/salesActivity/index.js.map +1 -0
  20. package/dist/cjs/types.d.ts +3 -0
  21. package/dist/cjs/types.js +3 -0
  22. package/dist/cjs/types.js.map +1 -0
  23. package/dist/esm/counterActivity/generated-types.d.ts +13 -0
  24. package/dist/esm/counterActivity/generated-types.js +2 -0
  25. package/dist/esm/counterActivity/generated-types.js.map +1 -0
  26. package/dist/esm/counterActivity/index.d.ts +5 -0
  27. package/dist/esm/counterActivity/index.js +66 -0
  28. package/dist/esm/counterActivity/index.js.map +1 -0
  29. package/dist/esm/generated-types.d.ts +5 -0
  30. package/dist/esm/generated-types.js +2 -0
  31. package/dist/esm/generated-types.js.map +1 -0
  32. package/dist/esm/index.d.ts +11 -0
  33. package/dist/esm/index.js +51 -0
  34. package/dist/esm/index.js.map +1 -0
  35. package/dist/esm/salesActivity/generated-types.d.ts +15 -0
  36. package/dist/esm/salesActivity/generated-types.js +2 -0
  37. package/dist/esm/salesActivity/generated-types.js.map +1 -0
  38. package/dist/esm/salesActivity/index.d.ts +5 -0
  39. package/dist/esm/salesActivity/index.js +88 -0
  40. package/dist/esm/salesActivity/index.js.map +1 -0
  41. package/dist/esm/types.d.ts +3 -0
  42. package/dist/esm/types.js +2 -0
  43. package/dist/esm/types.js.map +1 -0
  44. package/dist/tsconfig.tsbuildinfo +1 -0
  45. package/package.json +25 -0
  46. package/src/__tests__/counterActivity.test.ts +131 -0
  47. package/src/__tests__/salesActivity.test.ts +107 -0
  48. package/src/counterActivity/generated-types.ts +36 -0
  49. package/src/counterActivity/index.ts +76 -0
  50. package/src/generated-types.ts +16 -0
  51. package/src/index.ts +69 -0
  52. package/src/salesActivity/generated-types.ts +49 -0
  53. package/src/salesActivity/index.ts +98 -0
  54. package/src/types.ts +3 -0
  55. package/tsconfig.json +9 -0
package/README.md ADDED
@@ -0,0 +1,31 @@
1
+ # @segment/analytics-browser-actions-google-campaign-manager
2
+
3
+ The Google Campaign Manager browser action destination for use with @segment/analytics-next.
4
+
5
+ ## License
6
+
7
+ MIT License
8
+
9
+ Copyright (c) 2023 Segment
10
+
11
+ Permission is hereby granted, free of charge, to any person obtaining a copy
12
+ of this software and associated documentation files (the "Software"), to deal
13
+ in the Software without restriction, including without limitation the rights
14
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
+ copies of the Software, and to permit persons to whom the Software is
16
+ furnished to do so, subject to the following conditions:
17
+
18
+ The above copyright notice and this permission notice shall be included in all
19
+ copies or substantial portions of the Software.
20
+
21
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27
+ SOFTWARE.
28
+
29
+ ## Contributing
30
+
31
+ All third party contributors acknowledge that any contributions they provide will be made under the same open source license that the open source project is provided under.
@@ -0,0 +1,13 @@
1
+ export interface Payload {
2
+ activityGroupTagString: string;
3
+ activityTagString: string;
4
+ enableDynamicTags?: boolean;
5
+ countingMethod: string;
6
+ sessionId?: string;
7
+ uVariables?: {
8
+ [k: string]: unknown;
9
+ };
10
+ dcCustomParams?: {
11
+ [k: string]: unknown;
12
+ };
13
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=generated-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../../src/counterActivity/generated-types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,5 @@
1
+ import type { BrowserActionDefinition } from '@segment/browser-destination-runtime/types';
2
+ import type { Settings } from '../generated-types';
3
+ import type { Payload } from './generated-types';
4
+ declare const action: BrowserActionDefinition<Settings, Function, Payload>;
5
+ export default action;
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const action = {
4
+ title: 'Counter Activity',
5
+ description: 'Record non-monetary conversion data such as unique users, conversions, and session length.',
6
+ defaultSubscription: 'type = "track"',
7
+ platform: 'web',
8
+ fields: {
9
+ activityGroupTagString: {
10
+ label: 'Activity Group Tag String',
11
+ description: 'An identifier for the Floodlight activity group associated with this activity, which appears as a parameter in your tags. This value is case sensitive.',
12
+ type: 'string',
13
+ required: true
14
+ },
15
+ activityTagString: {
16
+ label: 'Activity Tag String',
17
+ description: 'An identifier for your Floodlight activity, which appears as a parameter in your tags. This value is case sensitive.',
18
+ type: 'string',
19
+ required: true
20
+ },
21
+ enableDynamicTags: {
22
+ label: 'Enable Dynamic Tags',
23
+ type: 'boolean',
24
+ description: 'In Campaign Manager, go to Floodlight -> Configuration, under Tags, if **Dynamic** is selected, select **True**.'
25
+ },
26
+ countingMethod: {
27
+ label: 'Counting Method',
28
+ type: 'string',
29
+ description: 'Specifies how conversions will be counted for this Floodlight activity.',
30
+ choices: [
31
+ { value: 'standard', label: 'Standard' },
32
+ { value: 'unique', label: 'Unique' },
33
+ { value: 'per_session', label: 'Per Session' }
34
+ ],
35
+ required: true
36
+ },
37
+ sessionId: {
38
+ label: 'Session ID',
39
+ description: 'Use this field to insert a unique session ID if you’re using counter tags with a per session counting methodology. The session ID tells Campaign Manager 360 to count only one event per session on your site.',
40
+ type: 'string'
41
+ },
42
+ uVariables: {
43
+ label: 'U Variables',
44
+ description: 'Custom Floodlight variables enable you to capture information beyond the basics (visits and revenue) that you can collect with standard parameters in your tags.',
45
+ type: 'object',
46
+ defaultObjectUI: 'keyvalue:only'
47
+ },
48
+ dcCustomParams: {
49
+ label: 'Custom Parameters',
50
+ description: 'You can insert custom data into event snippets with the dc_custom_params field. This field accepts any values you want to pass to Google Marketing Platform.',
51
+ type: 'object',
52
+ defaultObjectUI: 'keyvalue:only'
53
+ }
54
+ },
55
+ perform: (gtag, { payload, settings }) => {
56
+ const requestBody = {
57
+ allow_custom_scripts: payload.enableDynamicTags,
58
+ send_to: `${settings.advertiserId}/${payload.activityGroupTagString}/${payload.activityTagString}+${payload.countingMethod}`,
59
+ ...(payload.sessionId !== undefined &&
60
+ payload.countingMethod == 'per_session' && { session_id: payload.sessionId }),
61
+ ...payload.uVariables,
62
+ ...(payload.dcCustomParams !== undefined && { dc_custom_params: { ...payload.dcCustomParams } })
63
+ };
64
+ gtag('event', 'conversion', requestBody);
65
+ }
66
+ };
67
+ exports.default = action;
68
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":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jC;KACF;IACD,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE;QACvC,MAAM,WAAW,GAAG;YAClB,oBAAoB,EAAE,OAAO,CAAC,iBAAiB;YAC/C,OAAO,EAAE,GAAG,QAAQ,CAAC,YAAY,IAAI,OAAO,CAAC,sBAAsB,IAAI,OAAO,CAAC,iBAAiB,IAAI,OAAO,CAAC,cAAc,EAAE;YAC5H,GAAG,CAAC,OAAO,CAAC,SAAS,KAAK,SAAS;gBACjC,OAAO,CAAC,cAAc,IAAI,aAAa,IAAI,EAAE,UAAU,EAAE,OAAO,CAAC,SAAS,EAAE,CAAC;YAC/E,GAAG,OAAO,CAAC,UAAU;YACrB,GAAG,CAAC,OAAO,CAAC,cAAc,KAAK,SAAS,IAAI,EAAE,gBAAgB,EAAE,EAAE,GAAG,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC;SACjG,CAAA;QACD,IAAI,CAAC,OAAO,EAAE,YAAY,EAAE,WAAW,CAAC,CAAA;IAC1C,CAAC;CACF,CAAA;AAED,kBAAe,MAAM,CAAA"}
@@ -0,0 +1,5 @@
1
+ export interface Settings {
2
+ advertiserId: string;
3
+ allowAdPersonalizationSignals: boolean;
4
+ conversionLinker: boolean;
5
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=generated-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../src/generated-types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,11 @@
1
+ import type { Settings } from './generated-types';
2
+ import type { BrowserDestinationDefinition } from '@segment/browser-destination-runtime/types';
3
+ declare global {
4
+ interface Window {
5
+ gtag: Function;
6
+ dataLayer: any;
7
+ }
8
+ }
9
+ export declare const destination: BrowserDestinationDefinition<Settings, Function>;
10
+ declare const _default: import("@segment/browser-destination-runtime/types").PluginFactory;
11
+ export default _default;
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.destination = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const shim_1 = require("@segment/browser-destination-runtime/shim");
6
+ const counterActivity_1 = tslib_1.__importDefault(require("./counterActivity"));
7
+ const salesActivity_1 = tslib_1.__importDefault(require("./salesActivity"));
8
+ exports.destination = {
9
+ name: 'Google Tag for Campaign Manager',
10
+ slug: 'actions-google-campaign-manager',
11
+ mode: 'device',
12
+ settings: {
13
+ advertiserId: {
14
+ description: 'In Campaign Manager, go to Floodlight -> Configuration, and Advertiser ID is located under the Configuration heading.',
15
+ label: 'Advertiser ID',
16
+ type: 'string',
17
+ required: true,
18
+ default: 'DC-'
19
+ },
20
+ allowAdPersonalizationSignals: {
21
+ description: 'This feature can be disabled if you do not want the global site tag to allow personalized remarketing data for site users.',
22
+ label: 'Allow Ad Personalization Signals',
23
+ type: 'boolean',
24
+ required: true,
25
+ default: true
26
+ },
27
+ conversionLinker: {
28
+ description: 'This feature can be disabled if you do not want the global site tag to set first party cookies on your site domain.',
29
+ label: 'Conversion Linker',
30
+ type: 'boolean',
31
+ required: true,
32
+ default: true
33
+ }
34
+ },
35
+ initialize: async ({ settings }, deps) => {
36
+ window.dataLayer = window.dataLayer || [];
37
+ window.gtag = function () {
38
+ window.dataLayer.push(arguments);
39
+ };
40
+ window.gtag('set', 'allow_ad_personalization_signals', settings.allowAdPersonalizationSignals);
41
+ window.gtag('js', new Date());
42
+ window.gtag('config', settings.advertiserId, {
43
+ conversion_linker: settings.conversionLinker
44
+ });
45
+ const script = `https://www.googletagmanager.com/gtag/js?id=${settings.advertiserId}`;
46
+ await deps.loadScript(script);
47
+ return window.gtag;
48
+ },
49
+ actions: {
50
+ counterActivity: counterActivity_1.default,
51
+ salesActivity: salesActivity_1.default
52
+ }
53
+ };
54
+ exports.default = shim_1.browserDestination(exports.destination);
55
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1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M,MAAM,GAAG,+CAA+C,QAAQ,CAAC,YAAY,EAAE,CAAA;QACrF,MAAM,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAA;QAC7B,OAAO,MAAM,CAAC,IAAI,CAAA;IACpB,CAAC;IAED,OAAO,EAAE;QACP,eAAe,EAAf,yBAAe;QACf,aAAa,EAAb,uBAAa;KACd;CACF,CAAA;AAED,kBAAe,yBAAkB,CAAC,mBAAW,CAAC,CAAA"}
@@ -0,0 +1,15 @@
1
+ export interface Payload {
2
+ activityGroupTagString: string;
3
+ activityTagString: string;
4
+ enableDynamicTags?: boolean;
5
+ countingMethod: string;
6
+ transactionId: string;
7
+ value: string;
8
+ quantity: number;
9
+ uVariables?: {
10
+ [k: string]: unknown;
11
+ };
12
+ dcCustomParams?: {
13
+ [k: string]: unknown;
14
+ };
15
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=generated-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../../src/salesActivity/generated-types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,5 @@
1
+ import type { BrowserActionDefinition } from '@segment/browser-destination-runtime/types';
2
+ import type { Settings } from '../generated-types';
3
+ import type { Payload } from './generated-types';
4
+ declare const action: BrowserActionDefinition<Settings, Function, Payload>;
5
+ export default action;
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const action = {
4
+ title: 'Sales Activity',
5
+ description: 'Record monetary data for conversions, such as cost and the number of items sold.',
6
+ defaultSubscription: 'type = "track"',
7
+ platform: 'web',
8
+ fields: {
9
+ activityGroupTagString: {
10
+ label: 'Activity Group Tag String',
11
+ description: 'An identifier for the Floodlight activity group associated with this activity, which appears as a parameter in your tags. This value is case sensitive.',
12
+ type: 'string',
13
+ required: true
14
+ },
15
+ activityTagString: {
16
+ label: 'Activity Tag String',
17
+ description: 'An identifier for your Floodlight activity, which appears as a parameter in your tags. This value is case sensitive.',
18
+ type: 'string',
19
+ required: true
20
+ },
21
+ enableDynamicTags: {
22
+ label: 'Enable Dynamic Tags',
23
+ type: 'boolean',
24
+ description: 'In Campaign Manager, go to Floodlight -> Configuration, under Tags, if **Dynamic** is selected, select **True**.'
25
+ },
26
+ countingMethod: {
27
+ label: 'Counting Method',
28
+ type: 'string',
29
+ description: 'Specifies how conversions will be counted for this Floodlight activity.',
30
+ choices: [
31
+ { value: 'transactions', label: 'Transactions' },
32
+ { value: 'items_sold', label: 'Items Sold' }
33
+ ],
34
+ required: true
35
+ },
36
+ transactionId: {
37
+ label: 'Transaction ID',
38
+ description: 'Use this field to insert a unique numerical identifier for each transaction. Can be alphanumeric.',
39
+ type: 'string',
40
+ required: true,
41
+ default: {
42
+ '@path': '$.properties.order_id'
43
+ }
44
+ },
45
+ value: {
46
+ label: 'Value',
47
+ description: 'Use this field to pass the revenue generated by a transaction. Typically the purchase price and value does not include taxes or shipping.',
48
+ type: 'string',
49
+ required: true,
50
+ default: { '@path': '$.properties.total' }
51
+ },
52
+ quantity: {
53
+ label: 'Quantity',
54
+ description: `
55
+ Use this field to pass the number of items sold during a transaction:
56
+ - If you're counting each transaction as a single conversion, the value is 1.
57
+ - If you're counting each item sold during a single transaction as a separate conversion, insert the number of items sold as part of each transaction as the value.
58
+ - The value must be an integer greater than zero.
59
+ `,
60
+ type: 'integer',
61
+ required: true
62
+ },
63
+ uVariables: {
64
+ label: 'U Variables',
65
+ description: 'Custom Floodlight variables enable you to capture information beyond the basics (visits and revenue) that you can collect with standard parameters in your tags.',
66
+ type: 'object',
67
+ defaultObjectUI: 'keyvalue:only'
68
+ },
69
+ dcCustomParams: {
70
+ label: 'Custom Parameters',
71
+ description: 'You can insert custom data into event snippets with the dc_custom_params field. This field accepts any values you want to pass to Google Marketing Platform.',
72
+ type: 'object',
73
+ defaultObjectUI: 'keyvalue:only'
74
+ }
75
+ },
76
+ perform: (gtag, { payload, settings }) => {
77
+ const requestBody = {
78
+ allow_custom_scripts: payload.enableDynamicTags,
79
+ send_to: `${settings.advertiserId}/${payload.activityGroupTagString}/${payload.activityTagString}+${payload.countingMethod}`,
80
+ value: payload.value,
81
+ transaction_id: payload.transactionId,
82
+ quantity: payload.quantity,
83
+ ...payload.uVariables,
84
+ ...(payload.dcCustomParams !== undefined && { dc_custom_params: { ...payload.dcCustomParams } })
85
+ };
86
+ gtag('event', 'purchase', requestBody);
87
+ }
88
+ };
89
+ exports.default = action;
90
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/salesActivity/index.ts"],"names":[],"mappings":";;AAIA,MAAM,MAAM,GAAyD;IACnE,KAAK,EAAE,gBAAgB;IACvB,WAAW,EAAE,kFAAkF;IAC/F,mBAAmB,EAAE,gBAAgB;IACrC,QAAQ,EAAE,KAAK;IACf,MAAM,EAAE;QACN,sBAAsB,EAAE;YACtB,KAAK,EAAE,2BAA2B;YAClC,WAAW,EACT,yJAAyJ;YAC3J,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IAAI;SACf;QACD,iBAAiB,EAAE;YACjB,KAAK,EAAE,qBAAqB;YAC5B,WAAW,EACT,sHAAsH;YACxH,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IAAI;SACf;QACD,iBAAiB,EAAE;YACjB,KAAK,EAAE,qBAAqB;YAC5B,IAAI,EAAE,SAAS;YACf,WAAW,EACT,kHAAkH;SACrH;QACD,cAAc,EAAE;YACd,KAAK,EAAE,iBAAiB;YACxB,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,yEAAyE;YACtF,OAAO,EAAE;gBACP,EAAE,KAAK,EAAE,cAAc,EAAE,KAAK,EAAE,cAAc,EAAE;gBAChD,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,YAAY,EAAE;aAC7C;YACD,QAAQ,EAAE,IAAI;SACf;QACD,aAAa,EAAE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;SACjG,CAAA;QACD,IAAI,CAAC,OAAO,EAAE,UAAU,EAAE,WAAW,CAAC,CAAA;IACxC,CAAC;CACF,CAAA;AAED,kBAAe,MAAM,CAAA"}
@@ -0,0 +1,3 @@
1
+ export declare type GTAG = {
2
+ gtag: Function;
3
+ };
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,13 @@
1
+ export interface Payload {
2
+ activityGroupTagString: string;
3
+ activityTagString: string;
4
+ enableDynamicTags?: boolean;
5
+ countingMethod: string;
6
+ sessionId?: string;
7
+ uVariables?: {
8
+ [k: string]: unknown;
9
+ };
10
+ dcCustomParams?: {
11
+ [k: string]: unknown;
12
+ };
13
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=generated-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../../src/counterActivity/generated-types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,5 @@
1
+ import type { BrowserActionDefinition } from '@segment/browser-destination-runtime/types';
2
+ import type { Settings } from '../generated-types';
3
+ import type { Payload } from './generated-types';
4
+ declare const action: BrowserActionDefinition<Settings, Function, Payload>;
5
+ export default action;
@@ -0,0 +1,66 @@
1
+ const action = {
2
+ title: 'Counter Activity',
3
+ description: 'Record non-monetary conversion data such as unique users, conversions, and session length.',
4
+ defaultSubscription: 'type = "track"',
5
+ platform: 'web',
6
+ fields: {
7
+ activityGroupTagString: {
8
+ label: 'Activity Group Tag String',
9
+ description: 'An identifier for the Floodlight activity group associated with this activity, which appears as a parameter in your tags. This value is case sensitive.',
10
+ type: 'string',
11
+ required: true
12
+ },
13
+ activityTagString: {
14
+ label: 'Activity Tag String',
15
+ description: 'An identifier for your Floodlight activity, which appears as a parameter in your tags. This value is case sensitive.',
16
+ type: 'string',
17
+ required: true
18
+ },
19
+ enableDynamicTags: {
20
+ label: 'Enable Dynamic Tags',
21
+ type: 'boolean',
22
+ description: 'In Campaign Manager, go to Floodlight -> Configuration, under Tags, if **Dynamic** is selected, select **True**.'
23
+ },
24
+ countingMethod: {
25
+ label: 'Counting Method',
26
+ type: 'string',
27
+ description: 'Specifies how conversions will be counted for this Floodlight activity.',
28
+ choices: [
29
+ { value: 'standard', label: 'Standard' },
30
+ { value: 'unique', label: 'Unique' },
31
+ { value: 'per_session', label: 'Per Session' }
32
+ ],
33
+ required: true
34
+ },
35
+ sessionId: {
36
+ label: 'Session ID',
37
+ description: 'Use this field to insert a unique session ID if you’re using counter tags with a per session counting methodology. The session ID tells Campaign Manager 360 to count only one event per session on your site.',
38
+ type: 'string'
39
+ },
40
+ uVariables: {
41
+ label: 'U Variables',
42
+ description: 'Custom Floodlight variables enable you to capture information beyond the basics (visits and revenue) that you can collect with standard parameters in your tags.',
43
+ type: 'object',
44
+ defaultObjectUI: 'keyvalue:only'
45
+ },
46
+ dcCustomParams: {
47
+ label: 'Custom Parameters',
48
+ description: 'You can insert custom data into event snippets with the dc_custom_params field. This field accepts any values you want to pass to Google Marketing Platform.',
49
+ type: 'object',
50
+ defaultObjectUI: 'keyvalue:only'
51
+ }
52
+ },
53
+ perform: (gtag, { payload, settings }) => {
54
+ const requestBody = {
55
+ allow_custom_scripts: payload.enableDynamicTags,
56
+ send_to: `${settings.advertiserId}/${payload.activityGroupTagString}/${payload.activityTagString}+${payload.countingMethod}`,
57
+ ...(payload.sessionId !== undefined &&
58
+ payload.countingMethod == 'per_session' && { session_id: payload.sessionId }),
59
+ ...payload.uVariables,
60
+ ...(payload.dcCustomParams !== undefined && { dc_custom_params: { ...payload.dcCustomParams } })
61
+ };
62
+ gtag('event', 'conversion', requestBody);
63
+ }
64
+ };
65
+ export default action;
66
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index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ACD,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE;QACvC,MAAM,WAAW,GAAG;YAClB,oBAAoB,EAAE,OAAO,CAAC,iBAAiB;YAC/C,OAAO,EAAE,GAAG,QAAQ,CAAC,YAAY,IAAI,OAAO,CAAC,sBAAsB,IAAI,OAAO,CAAC,iBAAiB,IAAI,OAAO,CAAC,cAAc,EAAE;YAC5H,GAAG,CAAC,OAAO,CAAC,SAAS,KAAK,SAAS;gBACjC,OAAO,CAAC,cAAc,IAAI,aAAa,IAAI,EAAE,UAAU,EAAE,OAAO,CAAC,SAAS,EAAE,CAAC;YAC/E,GAAG,OAAO,CAAC,UAAU;YACrB,GAAG,CAAC,OAAO,CAAC,cAAc,KAAK,SAAS,IAAI,EAAE,gBAAgB,EAAE,EAAE,GAAG,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC;SACjG,CAAA;QACD,IAAI,CAAC,OAAO,EAAE,YAAY,EAAE,WAAW,CAAC,CAAA;IAC1C,CAAC;CACF,CAAA;AAED,eAAe,MAAM,CAAA"}
@@ -0,0 +1,5 @@
1
+ export interface Settings {
2
+ advertiserId: string;
3
+ allowAdPersonalizationSignals: boolean;
4
+ conversionLinker: boolean;
5
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=generated-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../src/generated-types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,11 @@
1
+ import type { Settings } from './generated-types';
2
+ import type { BrowserDestinationDefinition } from '@segment/browser-destination-runtime/types';
3
+ declare global {
4
+ interface Window {
5
+ gtag: Function;
6
+ dataLayer: any;
7
+ }
8
+ }
9
+ export declare const destination: BrowserDestinationDefinition<Settings, Function>;
10
+ declare const _default: import("@segment/browser-destination-runtime/types").PluginFactory;
11
+ export default _default;
@@ -0,0 +1,51 @@
1
+ import { browserDestination } from '@segment/browser-destination-runtime/shim';
2
+ import counterActivity from './counterActivity';
3
+ import salesActivity from './salesActivity';
4
+ export const destination = {
5
+ name: 'Google Tag for Campaign Manager',
6
+ slug: 'actions-google-campaign-manager',
7
+ mode: 'device',
8
+ settings: {
9
+ advertiserId: {
10
+ description: 'In Campaign Manager, go to Floodlight -> Configuration, and Advertiser ID is located under the Configuration heading.',
11
+ label: 'Advertiser ID',
12
+ type: 'string',
13
+ required: true,
14
+ default: 'DC-'
15
+ },
16
+ allowAdPersonalizationSignals: {
17
+ description: 'This feature can be disabled if you do not want the global site tag to allow personalized remarketing data for site users.',
18
+ label: 'Allow Ad Personalization Signals',
19
+ type: 'boolean',
20
+ required: true,
21
+ default: true
22
+ },
23
+ conversionLinker: {
24
+ description: 'This feature can be disabled if you do not want the global site tag to set first party cookies on your site domain.',
25
+ label: 'Conversion Linker',
26
+ type: 'boolean',
27
+ required: true,
28
+ default: true
29
+ }
30
+ },
31
+ initialize: async ({ settings }, deps) => {
32
+ window.dataLayer = window.dataLayer || [];
33
+ window.gtag = function () {
34
+ window.dataLayer.push(arguments);
35
+ };
36
+ window.gtag('set', 'allow_ad_personalization_signals', settings.allowAdPersonalizationSignals);
37
+ window.gtag('js', new Date());
38
+ window.gtag('config', settings.advertiserId, {
39
+ conversion_linker: settings.conversionLinker
40
+ });
41
+ const script = `https://www.googletagmanager.com/gtag/js?id=${settings.advertiserId}`;
42
+ await deps.loadScript(script);
43
+ return window.gtag;
44
+ },
45
+ actions: {
46
+ counterActivity,
47
+ salesActivity
48
+ }
49
+ };
50
+ export default browserDestination(destination);
51
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,2CAA2C,CAAA;AAC9E,OAAO,eAAe,MAAM,mBAAmB,CAAA;AAC/C,OAAO,aAAa,MAAM,iBAAiB,CAAA;AAS3C,MAAM,CAAC,M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O,MAAM,CAAC,IAAI,CAAA;IACpB,CAAC;IAED,OAAO,EAAE;QACP,eAAe;QACf,aAAa;KACd;CACF,CAAA;AAED,eAAe,kBAAkB,CAAC,WAAW,CAAC,CAAA"}
@@ -0,0 +1,15 @@
1
+ export interface Payload {
2
+ activityGroupTagString: string;
3
+ activityTagString: string;
4
+ enableDynamicTags?: boolean;
5
+ countingMethod: string;
6
+ transactionId: string;
7
+ value: string;
8
+ quantity: number;
9
+ uVariables?: {
10
+ [k: string]: unknown;
11
+ };
12
+ dcCustomParams?: {
13
+ [k: string]: unknown;
14
+ };
15
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=generated-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../../src/salesActivity/generated-types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,5 @@
1
+ import type { BrowserActionDefinition } from '@segment/browser-destination-runtime/types';
2
+ import type { Settings } from '../generated-types';
3
+ import type { Payload } from './generated-types';
4
+ declare const action: BrowserActionDefinition<Settings, Function, Payload>;
5
+ export default action;