-
Notifications
You must be signed in to change notification settings - Fork 11
/
index.html
573 lines (523 loc) · 20.3 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
<!DOCTYPE html>
<meta charset="utf-8">
<head>
<!-- Google Tag Manager -->
<script>(function (w, d, s, l, i) {
w[l] = w[l] || []; w[l].push({
'gtm.start':
new Date().getTime(), event: 'gtm.js'
}); var f = d.getElementsByTagName(s)[0],
j = d.createElement(s), dl = l != 'dataLayer' ? '&l=' + l : ''; j.async = true; j.src =
'https://www.googletagmanager.com/gtm.js?id=' + i + dl; f.parentNode.insertBefore(j, f);
})(window, document, 'script', 'dataLayer', 'GTM-MJ7NLLG');</script>
<!-- End Google Tag Manager -->
<title>E-commerce migration helper</title>
<style>
body {
font: 400 16px/24px Roboto, Noto Sans, Noto Sans JP, Noto Sans KR, Noto Naskh Arabic, Noto Sans Thai, Noto Sans Hebrew, Noto Sans Bengali, sans-serif;
margin: 10px;
}
section {
margin: 10px;
}
details {
margin: 15px 0;
cursor: pointer;
}
h2 {
margin: 50px 0px 30px;
color: #222;
}
h3,
h4 {
margin-top: 35px;
}
h4 {
margin-bottom: 8px;
}
hr {
margin: 50px 0;
}
#schema-not-submitted {
color: #999;
}
#schema-known {
color: darkgreen;
}
li.no-bullet {
list-style-type: none;
}
.hidden {
visibility: collapse;
height: 0px;
width: 0px;
overflow: hidden;
display: none;
}
label[for] {
cursor: pointer;
}
label {
color: #5f6368;
display: block;
font-size: 13px;
}
select.library {
-moz-appearance: none;
-webkit-appearance: none;
background-color: transparent;
border: 1px solid #e8eaed;
border-radius: 2px;
box-shadow: none;
color: #202124;
cursor: pointer;
display: inline-block;
font: 500 14px/36px Roboto, Noto Sans, Noto Sans JP, Noto Sans KR, Noto Naskh Arabic, Noto Sans Thai, Noto Sans Hebrew, Noto Sans Bengali, sans-serif;
height: 36px;
height: var(--devsite-select-height, 36px);
line-height: 34px;
line-height: var(--devsite-select-line-height, 34px);
max-width: 340px;
min-width: 72px;
outline: 0;
overflow: hidden;
padding: 0 27px 0 7px;
padding: var(--devsite-select-padding, 0 27px 0 7px);
text-align: left;
text-indent: .01px;
text-overflow: ellipsis;
-webkit-transition: background-color .2s;
transition: background-color .2s;
vertical-align: middle;
white-space: nowrap;
background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="4" viewBox="0 0 20 4"><path d="M0,0l4,4l4-4H0z" fill="%23212121"/></svg>') #fff no-repeat 100%;
margin: 10px 0;
}
button {
background: #fff;
background: var(--devsite-button-background, #fff);
border: 0;
border: var(--devsite-button-border, 0);
border-radius: 2px;
border-radius: var(--devsite-button-border-radius, 2px);
box-shadow: 0 1px 2px 0 rgba(60, 64, 67, .3), 0 1px 3px 1px rgba(60, 64, 67, .15);
box-shadow: var(--devsite-button-box-shadow, 0 1px 2px 0 rgba(60, 64, 67, .3), 0 1px 3px 1px rgba(60, 64, 67, .15));
color: #1a73e8;
color: var(--devsite-button-color, #1a73e8);
font: 500 14px/36px Roboto, Noto Sans, Noto Sans JP, Noto Sans KR, Noto Naskh Arabic, Noto Sans Thai, Noto Sans Hebrew, Noto Sans Bengali, sans-serif;
font: var(--devsite-button-font, 500 14px/36px Roboto, Noto Sans, Noto Sans JP, Noto Sans KR, Noto Naskh Arabic, Noto Sans Thai, Noto Sans Hebrew, Noto Sans Bengali, sans-serif);
height: 36px;
height: var(--devsite-button-height, 36px);
letter-spacing: 0;
letter-spacing: var(--devsite-button-letter-spacing, 0);
line-height: 36px;
line-height: var(--devsite-button-line-height, 36px);
max-width: none;
max-width: var(--devsite-button-max-width, none);
padding: 0 16px;
padding: var(--devsite-button-padding, 0 16px);
text-transform: uppercase;
text-transform: var(--devsite-button-text-transform, uppercase);
width: auto;
width: var(--devsite-button-width, auto);
-moz-appearance: none;
-webkit-appearance: none;
-moz-box-sizing: border-box;
box-sizing: border-box;
cursor: pointer;
display: inline-block;
margin: 0;
min-width: 36px;
outline: 0;
overflow: hidden;
text-align: center;
text-decoration: none;
text-overflow: ellipsis;
-webkit-transition: background-color .2s, border .2s, box-shadow .2s;
transition: background-color .2s, border .2s, box-shadow .2s;
vertical-align: middle;
white-space: nowrap;
background: #1a73e8;
background: var(--devsite-button-primary-background, #1a73e8);
color: #fff;
color: var(--devsite-button-primary-color, #fff);
line-height: 36px;
line-height: var(--devsite-button-primary-line-height, 36px);
margin: 25px 0;
width: 125px;
}
</style>
</head>
<body>
<h1>
Ecommerce migration helper
</h1>
<p>The ecommerce migration helper can assist with the following: </p>
<ul>
<li><b>Identification</b> of the version and tagging solution you're
currently using to send ecommerce events.</li>
<li><b>Validation</b> of how the ecommerce events you've implemented are
interpreted by Google Analytics tags in Google Tag Manager.</li>
<li><b>Recommend</b> how to transition your existing implementation to
equivalent GA4 events.</li>
</ul>
<p>Review the <a href="#help">Help</a> section to learn more about the <a
href="#help-purpose">Purpose</a> of the tool, <a href="#help-usage">How
to use the tool</a>, or to send <a href="#feedback">Feedback</a>.
</p>
<h2 id="configure">Enter details about your current implementation</h2>
<section>
<p>To run an analysis, select which library your current implementation uses
and provide an ecommerce event snippet to analyze. For detailed
instructions see <a href="#help-usage">How to use the tool</a>.
</p>
<h3 id="select-library">1. Which library does your current ecommerce
implementation use?</h3>
<p><select id="api" class="library">
<option value="dataLayer">Tag Manager - dataLayer.push(...);</option>
<option value="gtag">gtag.js - gtag('event', ...);</option>
</select>
</p>
<h3 id="analyzed-event">2. Provide an ecommerce event to analyze.</h3>
<p>Replace the default example below with the ecommerce event data you want
to analyze and click <b>Analyze</b>. The event data should be copied from
your existing ecommerce implementation. For additional help see <a
href="#help-usage">How to use the tool</a>.</p>
<div id="gtag">
<p>
<label for="gtag-event">Event name</label>
<textarea id="gtag-event" rows="1" cols="30">purchase</textarea>
</p>
<p>
<label for="gtag-params">Event parameters</label>
<textarea id="gtag-params" rows="30" cols="80">
{
"transaction_id": "123abc",
"value": 3.99,
"items": [
{
"item_id": "item_1",
"item_name": "Item 1",
"item_category": "Numbered Items",
"item_variant": "1",
"value": 1.99,
"quantity": 1
},
{
"item_id": "item_2",
"item_name": "Item 2",
"item_category": "Numbered Items",
"item_variant": "2",
"value": 2.00,
"quantity": 1
}
]
}
</textarea>
</p>
</div>
<div id="dataLayer">
<p>
<label for="dl-params">Data Layer update</label>
<textarea id="dl-params" rows="30" cols="80">
{
"event": "purchase",
"ecommerce": {
"purchase": {
"actionField": {
"id": "123abc",
"revenue": 3.99
},
"products": [
{
"id": "item_1",
"name": "Item 1",
"category": "Numbered Items",
"variant": "1",
"price": 1.99,
"quantity": 1
},
{
"id": "item_2",
"name": "Item 2",
"category": "Numbered Items",
"variant": "2",
"price": 2.00,
"quantity": 1
}
]
}
}
}
</textarea>
</p>
</div>
<div>
Google Analytics 4 Measurement ID:
<textarea id="ga4-property" rows="1" cols="30">G-EXAMPLE</textarea>
</div>
<div>
Universal Analytics Property ID:
<textarea id="ua-property" rows="1" cols="30">UA-12345-6</textarea>
</div>
<button id="submit">Analyze</button>
</section>
<h2 id="analysis">Results of analysis</h2>
<section>
<h3>Identification</h3>
<section>
<p>Identify the library and version of Google Analytics for the event
above.</p>
<div id="schema-not-submitted">Pending analysis...</div>
<div class="hidden" id="schema-known">
This appears to be a
<a class="hidden"
href="https://developers.google.com/tag-manager/enhanced-ecommerce"
id="schema-ua-gtm">Universal Analytics (Tag Manager) event</a>
<a class="hidden"
href="https://developers.google.com/tag-manager/ecommerce-ga4"
id="schema-ga4-gtm">Google Analytics 4 (Tag Manager) event</a>
<a class="hidden"
href="https://developers.google.com/analytics/devguides/collection/gtagjs/ecommerce"
id="schema-ua-gtag">Universal Analytics (gtag.js) event</a>
<a class="hidden"
href="https://developers.google.com/analytics/devguides/collection/ga4/ecommerce"
id="schema-ga4-gtag">Google Analytics 4 (gtag.js) event</a>
<span class="hidden" id="schema-gtag-unknown">
<a
href="https://developers.google.com/analytics/devguides/collection/gtagjs/ecommerce">Universal
Analytics (gtag.js) event</a> <b>OR</b> <a
href="https://developers.google.com/analytics/devguides/collection/ga4/ecommerce">Google
Analytics 4 (gtag.js) event</a>
</span>
.
</div>
<span class="hidden" id="schema-unknown">The data you entered is not
recognized as a Universal Analytics or a Google Analytics 4 event.
</span>
</section>
<h3>Validation</h3>
<section>
<p>Use the following information to confirm how the event above is
interpreted by various libraries and tag configurations.</p>
<h4 id="validation-ga4">Google Analytics 4</h4>
<p>
For the following configurations:</p>
<ul>
<li>Tag Manager <b>Google Analytics 4 event tag</b> with <b>Send
Ecommerce from Data Layer</b> enabled.
<ul>
<li class="no-bullet">
<details>
<summary>(Click to expand) Example GA4 event tag configuration
</summary>
<img src="./ga4_tag_config.png">
</details>
</li>
</ul>
</li>
<li>gtag.js configured with a GA4 property (not applicable when using
the Data Layer).</li>
</ul>
<p>Your <a href="#analyzed-event">event</a> above would be interpreted as
follows:</p>
<textarea id="ga4-result" readonly
cols="60">Click Analyze to generate data.</textarea>
<h4 id="validation-ua-ga4">Universal Analytics (GA4 support enabled)</h4>
<p>
For the following configurations:</p>
<ul>
<li>Tag Manager <b>Universal Analytics tag</b> with <b>Send Ecommerce
from Data Layer</b> and <b>Use GA4 events and parameters</b>
enabled.
<ul>
<li class="no-bullet">
<details>
<summary>(Click to expand) Example UA tag configuration
</summary>
<img src="./ua_with_ga4_config.png">
</details>
</li>
</ul>
</li>
<li>gtag.js configured with a UA property (not applicable when using
the Data Layer).</li>
</ul>
<p>Your <a href="#analyzed-event">event</a> above would be interpreted as
follows:</p>
<textarea id="ua-ga4-result" readonly
cols="60">Click Analyze to generate data.</textarea>
<h4 id="validation-ua-legacy">Universal Analytics</h4>
<p>
For the following configuration:</p>
<ul>
<li>Tag Manager <b>Universal Analytics tag</b> with <b>Send Ecommerce
from Data Layer</b> enabled (i.e. does not use GA4 events and
parameters).
<ul>
<li class="no-bullet">
<details>
<summary>(Click to expand) Example UA tag configuration
</summary>
<img src="./ua_legacy_config.png">
</details>
</li>
</ul>
</li>
</ul>
<p>Your <a href="#analyzed-event">event</a> above would be interpreted as
follows:</p>
<textarea id="ua-legacy-result" readonly
cols="60">Click Analyze to generate data.</textarea>
</section>
<h3 id="ga4-recommendation">Recommended GA4 event</h3>
<p>
To send your <a href="#analyzed-event">event</a> above as a GA4 event use
the following command:</p>
<textarea id="ga4-gtag-command" readonly cols="60">Click Analyze to generate data.
</textarea>
</section>
<hr>
<h2 id="help">Help</h2>
<section>
<h3 id="help-purpose">Purpose of the tool</h3>
<p>To simplify the transition from Universal Analytics to Google Analytics
4, ecommerce events and parameters for UA and GA4 are compatible in most,
but not all, cases. Review the guides available on the <a
href="https://developers.google.com/analytics/devguides/collection/upgrade/ga4">GA4
upgrade center</a> for details on compatibility and the pros/cons of
various upgrade options.</p>
<p>The ecommerce migration helper can be used to clarify the compatibility
of an event with various library/API and tag configurations. It helps with
the following:</p>
<ol>
<li>Identify which version and API/library is used to send the ecommerce
event to Google Analytics.
<ul>
<li>It will attempt to identify whether the event is Universal
Analytics, or Google Analytics 4 and which tagging solution was
used.</li>
<li><b>Why?</b>: Identify your current implementation, if you're not
sure.</li>
</ul>
</li>
<li>Validate how your implementation is interpreted by Google Analytics
tags in Google Tag Manager.
<ul>
<li>How the event is interpreted by various tag configurations. For
example, if the event you provide is a UA purchase event sent using
the Data Layer the tool can show how that event and associated
parameters map to the equivalent GA4 event.</li>
<li><b>Why?</b> (1) confirm your ecommerce events are well-formed and
(2) understand how data maps to equivalent parameters (or doesn't)
when sending GA4 events to a UA property or sending UA events to GA4
property.</li>
</ul>
<li>Recommend how to transition the event to an equivalent GA4 event.
<ul>
<li><b>Why?</b> To assist with transitioning the your implementation
to the recommended GA4 format.</li>
</ul>
</li>
</ol>
<h3 id="help-usage">How to use the tool</h3>
<h4>Enter details about your current implementation</h4>
<p><a href="#configure">Configure</a> the tool by selecting which
library/API you're using to send ecommerce data and provide the details of
the ecommerce event you want to analyze. <b>Note:</b> The tool is
preconfigured with a default example for both the <i>dataLayer.push
API</i> and <i>gtag API</i> cases.</p>
<ul>
<li><b>Tag Manager - dataLayer.push(...);</b>
<ul>
<li>The default example is a GA4 purchase ecommerce event sent to
Google Analytics using the <a
href="https://developers.google.com/tag-manager/reference#datalayer.push">Data
Layer update</a> method. For comparison, see a similar <a
href="https://developers.google.com/tag-manager/ecommerce-ga4#measure_purchases">GA4
purchase example snippet</a>.
</li>
<li>In the <b>Data Layer update</b> input field, provide the ecommerce
event object to analyze. Only include the key/value
pairs and not the <code>dataLayer.push</code> method call. All
objects must include an <code>event</code> key. If your
implementation does not have an <code>event</code> key because the
event is triggered automatically (e.g. DOM load) then you'll need to
add an <code>event</code> key to use the tool.
<ul>
<li>The <a href="#ga4-recommendation">GA4 recommendation</a>
result will not work if you use custom event names. Instead use
the recommended GA4 event name for the corresponding ecommerce
action. See <a
href="https://developers.google.com/analytics/devguides/collection/upgrade/ga4/gtm-ga4-to-ua#ua-ga4-events">UA
ecommerce activities and equivalent GA4 Event names</a> to
determine the correct event name. For example, a product click
event using a custom event name of <code>productClick</code>
would need to be updated from:<br>
<code>{'event': 'productClick', 'ecommerce': {...}}</code><br>
to:<br>
<code>{'event': 'select_item', 'ecommerce': {...}}</code>
</li>
</ul>
</li>
</ul>
</li>
<li><b>gtag.js - gtag('event', ...);</b>
<ul>
<li>The default example is a GA4 purchase ecommerce event sent to
Google Analytics using the <a
href="https://developers.google.com/gtagjs/reference/api#event">gtag.js
API</a>. For comparison, see a similar <a
href="https://developers.google.com/analytics/devguides/collection/ga4/ecommerce#purchase">GA4
purchase example snippet</a>.
</li>
<li>Event name and parameters are entered separately in the <b>Event
name</b> and <b>Event
parameters</b> input fields, respectively. For ecommerce
parameters, only provide the ecommerce object and not the
<code>gtag()</code> function call.
</li>
</ul>
</li>
</ul>
<h4 id="help-results">Results of analysis</h4>
<p>The <b>Identification</b> section attempts to identify the library/API
used to send the ecommerce data and the Google Analytics version for
which the data is formatted.</p>
<p>The <b>Validation</b> section shows how the event is interpreted for
various Google Analytics configurations.</p>
<p>The <b>Recommended GA4 event</b> section attempts to generate the
corresponding GA4 event for the provided event.</p>
<h5>Example</h5>
<p>Analyze the default gtag.js example, a purchase event using
the <i>gtag API</i>, the results are as follows:</p>
<ul>
<li><b>Identification</b>: The example uses the <b>gtag API</b> and the
GA4 ecommerce data format.</li>
<li><b>Validation</b>:
<ul>
<li><a href="#validation-ga4">Google Analytics 4</a> and <a
href="#validation-ua-ga4">Universal Analytics (GA4 support
enabled)</a> configurations both read the ecommerce data as shown
in the analysis results. The <a
href="#validation-ua-legacy">Universal Analytics</a> tag without
GA4 support enabled will not read the ecommerce data sent and the
<code>No ecommerce data found</code> message is shown.
</li>
</ul>
</li>
<li><b>Recommendation</b>: The command to send the event using the gtag
API is shown. Since the default event uses the gtag API to send a GA4
event, there is no difference.
</li>
</ul>
</section>
<h2 id="feedback">Feedback / Report an issue</h2>
<section>
<p>To view open issues, send feedback or report an issue, see <a
href="https://github.com/googleanalytics/ecommerce-migration-helper/issues">ecommerce-migration-helper</a>.
</p>
</section>
<script src="./main.js" type="module"></script>
</body>
</html>