-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathutm.html
340 lines (331 loc) · 21.2 KB
/
utm.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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta http-equiv="Accept-CH" content="DPR, Viewport-Width, Width, Content-DPR, Downlink, Save-Data">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Google Analytics 4 UTM Campaign URL Builder</title>
<style>
:root {
--black: rgba(0, 0, 0, .8);
--blue-dark: rgb(0, 112, 201);
--blue-light: rgb(102, 187, 255);
--gray: rgb(204, 204, 204);
--white: rgba(255, 255, 255, 1);
}
html {
overflow-y: scroll;
overflow-x: hidden;
-webkit-text-size-adjust: 100%;
-ms-text-size-adjust: 100%;
}
body {
margin: 1% auto;
padding: 0 3%;
max-width: 30em;
background-color: rgba(0, 0, 0, 0);
color: var(--black);
font-family: BlinkMacSystemFont, -apple-system, "Segoe UI", system-ui, Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
font-size: 1.125rem;
line-height: 1.618;
}
footer, small {
font-size: 80%;
}
b, dt, strong {
font-weight: 700;
}
h1, h2, h3 {
line-height: 1.2;
letter-spacing: .02em;
}
a {
background-color: transparent;
color: var(--blue-dark);
text-decoration: none;
text-decoration-skip: ink;
-ms-touch-action: manipulation;
touch-action: manipulation;
}
a:hover, a:active, a:focus {
color: var(--blue-light);
}
abbr[title] {
text-decoration: none;
}
code {
font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, Monaco, "Courier New", monospace;
font-size: 1em;
}
input, textarea {
width: 95%;
display: block;
padding: .5em 1%;
font-size: 1em;
}
fieldset, input, textarea {
margin-bottom: 1.5em;
}
label > p {
margin: 0;
}
hr {
border: 0;
border-top: 1px solid var(--gray);
}
@media (prefers-color-scheme: dark) {
body {
background-color: var(--black);
color: var(--white);
word-spacing: .05em;
}
a {
color: var(--blue-light);
}
a:hover, a:active, a:focus {
color: var(--blue-dark);
}
input, select, textarea {
background-color: var(--black);
color: var(--white);
}
input:invalid {
border: 5px dashed red;
}
}
#wrapper {
margin: auto;
width: 70%;
font-family: sans-serif;
}
.grid-container {
display: grid;
grid-template-rows: 50px;
grid-template-areas: '. . .';
padding-bottom: 10px;
}
.box-good {
background-color: hsl(118, 41%, 49%);
}
.box-needs-improvement {
background-color: hsl(31, 78%, 53%);
}
.box-poor {
background-color: hsl(359, 80%, 50%);
}
</style>
<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://gtm.vreeman.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);})(window,document,'script','dataLayer','GTM-WKSDWK');</script>
<link rel="canonical" href="https://vreeman.com/utm">
<link rel="alternate" href="https://vreeman.com/utm" hreflang="x-default">
<link rel="alternate" href="https://vreeman.com/utm" hreflang="en">
<meta name="description" content="A simple tool to easily add UTM tags for Google Analytics 4 to your URL. And you can check the URL for Pagespeed, Structured Data or Facebook Open Graph.">
<meta property="og:title" content="Google Analytics 4 UTM Campaign URL Builder">
<meta property="og:url" content="https://vreeman.com/utm">
<meta property="og:description" content="A simple tool to easily add UTM tags for Google Analytics 4 to your URL. And you can check the URL for Pagespeed, Structured Data or Facebook Open Graph.">
<meta property="og:image" content="https://vreeman.com/img/tile-wide.png">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:site" content="@vreeman">
<meta name="twitter:creator" content="@vreeman">
<meta name="twitter:title" content="Google Analytics 4 UTM Campaign URL Builder">
<meta name="twitter:description" content="A simple tool to easily add UTM tags for Google Analytics 4 to your URL. And you can check the URL for Pagespeed, Structured Data or Facebook Open Graph.">
<meta name="twitter:image" content="https://vreeman.com/img/tile-wide.png">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="apple-mobile-web-app-title" content="URL Builder">
<link rel="apple-touch-icon" href="apple-touch-icon.png">
<meta name="theme-color" content="#000">
</head>
<body>
<noscript><iframe src="https://gtm.vreeman.com/ns.html?id=GTM-WKSDWK" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<header>
<h1>Google Analytics 4 <abbr title="Urchin Tracking Module">UTM</abbr> Campaign <abbr title="Uniform Resource Locator">URL</abbr> Builder</h1>
<p><a href="https://vreeman.com/" title="Simon Vreeman">Home</a> | <a href="https://vreeman.com/cro" title="CRO Tools"><abbr title="Conversion Rate Optimization">CRO</abbr> Tools</a></p>
</header>
<p>A simple tool to create an <abbr title="Uniform Resource Locator">URL</abbr> with <a href="https://support.google.com/analytics/answer/11242870?hl=en" rel="nofollow noopener noreferrer" target="_blank">Google Analytics 4 <abbr title="Urchin Tracking Module">UTM</abbr> campaign parameters</a> for your <a href="https://support.google.com/analytics/answer/10917952?hl=en" rel="nofollow noopener noreferrer" target="_blank">manual tagging marketing campaigns</a>. A couple of features; All input will be lowercase appended to the <abbr title="Uniform Resource Locator">URL</abbr>. The Google Analytics <abbr title="Urchin Tracking Module">UTM</abbr> Campaign <abbr title="Uniform Resource Locator">URL</abbr> Builder will check if the <abbr title="Uniform Resource Locator">URL</abbr> already contains parameters and if it returns an <abbr title="Hypertext Transfer Protocol">HTTP</abbr> response status code. Preferably a <code>200</code> status code. With one click you add the <abbr title="Uniform Resource Locator">URL</abbr> to your clipboard.</p>
<p>Make sure you are strict in using <code>utm_source</code> and <code>utm_medium</code>. Otherwise, you will end up with a lot of traffic in the (other) or unassigned Default Channel Groupings. More information about the Default Channel Grouping definitions and rules can be found <a href="https://support.google.com/analytics/answer/3297892?hl=en" rel="nofollow noopener noreferrer" target="_blank">here for Universal</a> and <a href="https://support.google.com/analytics/answer/9756891?hl=en" rel="nofollow noopener noreferrer" target="_blank">here for GA4</a>.</p>
<form onkeyup="getUTM()">
<fieldset>
<legend><abbr title="Uniform Resource Locator">URL</abbr>, Source and Medium are required</legend>
<label for="campaigns">Predefined campaigns</label>
<select id="campaigns">
<option value="optional" selected>Optional</option>
<option value="email">Email</option>
</select>
<br>
<label for="domain"><abbr title="Uniform Resource Locator">URL</abbr> without <abbr title="Urchin Tracking Module">UTM</abbr> tags</label>
<input type="url" inputmode="url" name="domain" id="domain" autocapitalize="none" autocomplete="off" enterkeyhint="next" placeholder="Required" autofocus required>
<label for="source">
<p>Campaign Source <code>[utm_source]</code></p>
<p><small>Dimensions in GA4: Source, First user source, Session source</small></p>
</label>
<input type="text" name="source" id="source" autocapitalize="none" enterkeyhint="next" placeholder="Required" required>
<label for="medium">
<p>Campaign Medium <code>[utm_medium]</code></p>
<p><small>Dimensions in GA4: Medium, First user medium, Session medium</small></p>
</label>
<input type="text" name="medium" id="medium" autocapitalize="none" enterkeyhint="next" placeholder="Required" required>
<label for="name">
<p>Campaign Name <code>[utm_campaign]</code></p>
<p><small>Dimensions in GA4: Campaign, First user campaign, Session campaign</small></p>
</label>
<input type="text" name="name" id="name" autocapitalize="none" enterkeyhint="next" placeholder="Optional">
<label for="term">
<p>Campaign Term <code>[utm_term]</code></p>
<p><small>Dimensions in GA4: Manual term, Session manual term, First user manual term</small></p>
</label>
<input type="text" name="term" id="term" autocapitalize="none" enterkeyhint="next" placeholder="Optional">
<label for="content">
<p>Campaign Content <code>[utm_content]</code></p>
<p><small>Dimensions in GA4: Manual ad content, Session manual ad content, First user manual ad content</small></p>
</label>
<input type="text" name="content" id="content" autocapitalize="none" enterkeyhint="next" placeholder="Optional">
<label for="platform">
<p>Source platform <code>[utm_source_platform]</code></p>
<p><small>Dimensions in GA4: Source platform, Session source platform, First user source platform</small></p>
</label>
<input type="text" name="platform" id="platform" autocapitalize="none" enterkeyhint="next" placeholder="Optional">
<label for="format">
<p>Creative format <code>[utm_creative_format]</code></p>
<p><small>Dimensions in GA4: Creative format, Session creative format, First user creative format</small></p>
</label>
<input type="text" name="format" id="format" autocapitalize="none" enterkeyhint="next" placeholder="Optional">
<label for="tactic">
<p>Marketing tactic <code>[utm_marketing_tactic]</code></p>
<p><small>Dimensions in GA4: Marketing tactic, Session marketing tactic, First user marketing tactic</small></p>
</label>
<input type="text" name="tactic" id="tactic" autocapitalize="none" enterkeyhint="done" placeholder="Optional">
</fieldset>
</form>
<label for="url">The <abbr title="Uniform Resource Locator">URL</abbr> with <abbr title="Urchin Tracking Module">UTM</abbr> tags</label>
<textarea id="url" readonly="readonly" wrap="off" onclick="this.focus();this.select()" rows="3">https://vreeman.com</textarea>
<p><abbr title="Hypertext Transfer Protocol">HTTP</abbr> response status code: <b><span id="statuscode"></span></b></p>
<button onclick="copyURL()">Copy URL with <abbr title="Urchin Tracking Module">UTM</abbr></button>
<h2>Check the URL with more tools</h2>
<ul>
<li><a id="pagespeed" href="https://developers.google.com/speed/pagespeed/insights/?url=https://vreeman.com" rel="nofollow noopener noreferrer" target="_blank">Check Pagespeed Insights</a></li>
<li><a id="richresults" href="https://search.google.com/test/rich-results?url=https://vreeman.com" rel="nofollow noopener noreferrer" target="_blank">Check Rich Results</a></li>
<li><a id="schemaorg" href="https://validator.schema.org/#url=https://vreeman.com" rel="nofollow noopener noreferrer" target="_blank">Check with Schema.org Validator</a></li>
<li><a id="safebrowsing" href="https://www.google.com/transparencyreport/safebrowsing/diagnostic/index.html#url=https://vreeman.com" rel="nofollow noopener noreferrer" target="_blank">Check Safe Browsing Site Status</a></li>
<li><a id="mobilefriendly" href="https://search.google.com/test/mobile-friendly?url=https://vreeman.com" rel="nofollow noopener noreferrer" target="_blank">Check Mobile-Friendliness</a></li>
<li><a id="bing" href="https://www.bing.com/webmasters/urlinspection?urlToInspect=https://vreeman.com" rel="nofollow noopener noreferrer" target="_blank">Check in Bing Webmaster Tools</a></li>
<li><a id="twitter" href="https://cards-dev.twitter.com/validator" rel="nofollow noopener noreferrer" target="_blank">Check Twitter Validator</a></li>
<li><a id="facebook" href="https://developers.facebook.com/tools/debug/sharing/?q=https://vreeman.com" rel="nofollow noopener noreferrer" target="_blank">Check Facebook Debugger</a></li>
<li><a id="opengraph" href="https://developers.facebook.com/tools/debug/og/object/?q=https://vreeman.com" rel="nofollow noopener noreferrer" target="_blank">Check Open Graph Object Debugger</a></li>
<li><a id="pinterest" href="https://developers.pinterest.com/tools/url-debugger/?link=https://vreeman.com" rel="nofollow noopener noreferrer" target="_blank">Check Pinterest</a></li>
<li><a id="linkedin" href="https://www.linkedin.com/post-inspector/inspect/https:%2F%2Fvreeman.com" rel="nofollow noopener noreferrer" target="_blank">Check LinkedIn</a></li>
<li><a id="fullcache" href="http://webcache.googleusercontent.com/search?q=cache:https://vreeman.com/&num=1&hl=en&gl=en&strip=0&vwsrc=0" rel="nofollow noopener noreferrer" target="_blank">Full version Google Cache</a></li>
<li><a id="textcache" href="http://webcache.googleusercontent.com/search?q=cache:https://vreeman.com/&num=1&hl=en&gl=en&strip=1&vwsrc=0" rel="nofollow noopener noreferrer" target="_blank">Text-only version Google Cache</a></li>
<li><a id="sourcecache" href="http://webcache.googleusercontent.com/search?q=cache:https://vreeman.com/&num=1&hl=en&gl=en&strip=0&vwsrc=1" rel="nofollow noopener noreferrer" target="_blank">View source via Google Cache</a></li>
<li><a id="ssl" href="https://www.ssllabs.com/ssltest/analyze.html?d=https://vreeman.com" rel="nofollow noopener noreferrer" target="_blank">SSL Server Test</a></li>
<li><a id="mozilla" href="https://observatory.mozilla.org/" rel="nofollow noopener noreferrer" target="_blank">Mozilla Observatory</a></li>
<li><a id="resourcehint" href="https://www.debugbear.com/resource-hint-validator?url=https://vreeman.com" rel="nofollow noopener noreferrer" target="_blank">Browser Resource Hint Validator</a></li>
</ul>
<!-- <hr>
<div id="wrapper">
<h1>Chrome User Experience Report API demo</h1>
<p>The field data collected over the last 28 days.</p>
</div>
<hr> -->
<p>Besides this Google Analytics 4 UTM Campaign URL Builder I made a list of handy <a href="https://vreeman.com/cro" title="CRO Tools"><abbr title="Conversion Rate Optimization">CRO</abbr> tools</a>, <a href="https://vreeman.com/mp" title="Google Analytics Measurement Protocol Hit Builder">Google Analytics Measurement Protocol Hit Builder</a> and <a href="https://vreeman.com/hypothesis" title="A/B Test Hypothesis Builder">Experiment Hypothesis Builder</a>.</p>
<hr>
<footer>
<p>Vreeman.com is the personal website of <a class="h-card" rel="me" href="https://vreeman.com" title="Simon Vreeman">Simon Vreeman</a>.</p>
<dl>
<dt>Privacy & Cookie Policy</dt>
<dd>Vreeman.com uses Google Analytics (<code>_ga</code>, <code>FPID</code>, & <code>FPLC</code>), and Google Tag Manager Server-side to measure and analyze anonymous user behavior data to improve the website in an ethical manner.</dd>
<dt>Colophon</dt>
<dd>Vreeman.com uses Cloudflare Pages to ensure it loads fast and the source code is hosted on Github.</dd>
<dt>Licenses</dt>
<dd>Text is licensed under <a href="https://creativecommons.org/licenses/by/4.0/" rel="license" title="Creative Commons Attribution 4.0 International License" data-vars-outbound-text="Creative Commons License" data-vars-outbound-link="https://creativecommons.org/licenses/by/4.0/">Creative Commons Attribution 4.0 International License</a>. <code></></code> is licensed under <a href="https://opensource.org/licenses/MIT" rel="license" title="MIT License" data-vars-outbound-text="MIT License" data-vars-outbound-link="https://opensource.org/licenses/MIT">MIT License</a>.</dd>
<dt>Other</dt>
<dd>
<ul>
<li><a href="https://vreeman.com/cro" title="CRO (Conversion Rate Optimization) Tools" data-vars-outbound-text="CRO Tools" data-vars-outbound-link="https://vreeman.com/cro"><abbr title="Conversion Rate Optimization">CRO</abbr> Tools</a></li>
<li><a href="https://vreeman.com/gear" title="What is in my backpack?" data-vars-outbound-text="Travel Gear" data-vars-outbound-link="https://vreeman.com/gear">Travel Gear</a></li>
<li><a href="https://vreeman.com/meditations/" title="Meditations by Marcus Aurelius. Translations by Gregory Hays." data-vars-outbound-text="Meditations" data-vars-outbound-link="https://vreeman.com/meditations/">Meditations by Marcus Aurelius. Translations by Gregory Hays.</a></li>
<li><a href="https://vreeman.com/discourses/" title="Discourses of Epictetus. Translated and edited by Robert Dobbin" data-vars-outbound-text="Discourses" data-vars-outbound-link="https://vreeman.com/discourses/">Discourses of Epictetus. Translated and edited by Robert Dobbin.</a></li>
</ul>
</dd>
</dl>
</footer>
<script>
function getUTM() {
var campaigns = document.getElementById("campaigns").options[document.getElementById("campaigns").selectedIndex].value;
var domain = document.getElementById("domain").value;
var encodedomain = encodeURIComponent(domain).replace(/'/g,"%27").replace(/"/g,"%22");
var source = document.getElementById("source").value.toLowerCase();
var medium = document.getElementById("medium").value.toLowerCase();
var name = document.getElementById("name").value.toLowerCase();
var term = document.getElementById("term").value.toLowerCase();
var content = document.getElementById("content").value.toLowerCase();
var platform = document.getElementById("platform").value.toLowerCase();
var format = document.getElementById("format").value.toLowerCase();
var tactic = document.getElementById("tactic").value.toLowerCase();
var url = document.getElementById("url");
var statuscode = document.getElementById("statuscode");
var html;
if (campaigns === 'email') {
medium = document.getElementById("medium").value = "email";
}
if (domain.indexOf("?") != -1) {
html = domain + '&utm_source=' + encodeURIComponent(source) + '&utm_medium=' + encodeURIComponent(medium);
} else {
html = domain + '?utm_source=' + encodeURIComponent(source) + '&utm_medium=' + encodeURIComponent(medium);
}
if (name) {
html = html + '&utm_campaign='+encodeURIComponent(name);
}
if (term) {
html = html + '&utm_term='+encodeURIComponent(term);
}
if (content) {
html = html + '&utm_content='+encodeURIComponent(content);
}
if (platform) {
html = html + '&utm_source_platform='+encodeURIComponent(platform);
}
if (format) {
html = html + '&utm_creative_format='+encodeURIComponent(format);
}
if (tactic) {
html = html + '&utm_marketing_tactic='+encodeURIComponent(tactic);
}
url.textContent = html;
var httpRequest = new Request( html );
fetch(httpRequest).then(function(response) {
statuscode.textContent = response.status;
});
if (!domain || !source || !medium) {
console.log("Domain, Source, and Medium are required fields.");
return;
}
pagespeed.href = "https://developers.google.com/speed/pagespeed/insights/?url=" + domain;
richresults.href = "https://search.google.com/test/rich-results?url=" + domain;
schemaorg.href = "https://validator.schema.org/#url=" + domain;
safebrowsing.href = "https://www.google.com/transparencyreport/safebrowsing/diagnostic/index.html#url=" + domain;
mobilefriendly.href = "https://search.google.com/test/mobile-friendly?url=" + domain;
bing.href = "https://www.bing.com/webmasters/urlinspection?urlToInspect=" + domain;
twitter.href = "https://cards-dev.twitter.com/validator?url=" + domain;
facebook.href = "https://developers.facebook.com/tools/debug/sharing/?q=" + domain;
opengraph.href = "https://developers.facebook.com/tools/debug/og/object/?q=" + domain;
pinterest.href = "https://developers.pinterest.com/tools/url-debugger/?link=" + domain;
linkedin.href = "https://www.linkedin.com/post-inspector/inspect/" + encodedomain;
fullcache.href = "http://webcache.googleusercontent.com/search?q=cache:" + domain + "&num=1&hl=en&gl=en&strip=0&vwsrc=0";
textcache.href = "http://webcache.googleusercontent.com/search?q=cache:" + domain + "&num=1&hl=en&gl=en&strip=1&vwsrc=0";
sourcecache.href = "http://webcache.googleusercontent.com/search?q=cache:" + domain + "&num=1&hl=en&gl=en&strip=0&vwsrc=1";
resourcehint.href = "https://www.debugbear.com/resource-hint-validator?url=" + domain;
ssl.href = "https://www.ssllabs.com/ssltest/analyze.html?d=" + domain;
}
</script>
<script>
function copyURL() {
navigator.clipboard.writeText(document.getElementById("url").value).then(() => {
alert("URL copied to clipboard!");
}).catch(err => {
console.error("Could not copy text: ", err);
});
}
</script>
</body>
</html>