Skip to content

Commit 92fc97c

Browse files
committed
Update Google Analytics Code
Update Google Analytics Code for Version 4
1 parent 8e70414 commit 92fc97c

File tree

3 files changed

+34
-28
lines changed

3 files changed

+34
-28
lines changed

_includes/footer.html

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -29,28 +29,3 @@ <h3>Connect</h3>
2929
</div>
3030
</div>
3131
</footer>
32-
33-
<script>
34-
(function (i, s, o, g, r, a, m) {
35-
i['GoogleAnalyticsObject'] = r;
36-
(i[r] =
37-
i[r] ||
38-
function () {
39-
(i[r].q = i[r].q || []).push(arguments);
40-
}),
41-
(i[r].l = 1 * new Date());
42-
(a = s.createElement(o)), (m = s.getElementsByTagName(o)[0]);
43-
a.async = 1;
44-
a.src = g;
45-
m.parentNode.insertBefore(a, m);
46-
})(
47-
window,
48-
document,
49-
'script',
50-
'//www.google-analytics.com/analytics.js',
51-
'ga'
52-
);
53-
54-
ga('create', 'UA-74039819-1', 'auto');
55-
ga('send', 'pageview');
56-
</script>

_includes/head.html

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,30 @@
3636
src="https://www.facebook.com/tr?id=968280476930527&ev=PageView&noscript=1"
3737
/></noscript>
3838
<!-- End Facebook Pixel Code -->
39+
<!-- Global site tag (gtag.js) - Google Analytics -->
40+
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-74039819-1"></script>
41+
<script>
42+
window.dataLayer = window.dataLayer || [];
43+
function gtag(){dataLayer.push(arguments);}
44+
gtag('js', new Date());
45+
46+
gtag('config', 'UA-74039819-1');
47+
</script>
48+
<script>
49+
/**
50+
* Function that registers a click on an outbound link in Analytics.
51+
* This function takes a valid URL string as an argument, and uses that URL string
52+
* as the event label. Setting the transport method to 'beacon' lets the hit be sent
53+
* using 'navigator.sendBeacon' in browser that support it.
54+
*/
55+
var getOutboundLink = function(url) {
56+
gtag('event', 'click', {
57+
'event_category': 'outbound',
58+
'event_label': url,
59+
'transport_type': 'beacon',
60+
'event_callback': function(){document.location = url;}
61+
});
62+
}
63+
</script>
3964

4065
</head>

index.html

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44

55
<div class="centered">
66
<h1>Code for Boston</h1>
7-
<h3>
7+
<h2>
88
A
99
<a href="https://www.codeforamerica.org/" target="_blank"
1010
>Code for America</a
1111
>
1212
brigade and grassroots organization.
13-
</h3>
13+
</h2>
1414

1515
<p>
1616
Code for Boston addresses local social and civic challenges through creative
@@ -35,8 +35,11 @@ <h3>
3535
<a
3636
href="{{ site.slack_url }}"
3737
class="btn-secondary"
38+
onclick="getOutboundLink('https://communityinviter.com/apps/cfb-public/default-badge'); return false;"
3839
>Say hi on Slack</a>
39-
<a href="" class="btn-secondary">Weekly E-Mail Newsletter</a>
40+
<a href="http://eepurl.com/5UcLX"
41+
onclick="getOutboundLink('http://eepurl.com/5UcLX'); return false;"
42+
class="btn-secondary">Weekly E-Mail Newsletter</a>
4043
</div>
4144

4245
<div>
@@ -49,11 +52,14 @@ <h3>
4952
</p>
5053
<div class="btn-group">
5154
<a href="https://codeforamerica.zoom.us/meeting/register/tJIud-Corj0sGNaJai1FmkyfRMek27MzEC_X"
55+
onclick="getOutboundLink('https://codeforamerica.zoom.us/meeting/register/tJIud-Corj0sGNaJai1FmkyfRMek27MzEC_X'); return false;"
5256
class="btn-secondary">RSVP on Zoom</a>
5357
<a href="https://communityinviter.com/apps/bostoncivictechcoffee/civic-tech-coffee"
58+
onclick="getOutboundLink('https://communityinviter.com/apps/bostoncivictechcoffee/civic-tech-coffee'); return false;"
5459
class="btn-secondary"
5560
>Say hi on Slack</a>
5661
<a href="http://eepurl.com/g3AxjX"
62+
onclick="getOutboundLink('http://eepurl.com/g3AxjX'); return false;"
5763
class="btn-secondary"
5864
>
5965
Monthly E-Mail Reminders

0 commit comments

Comments
 (0)