Skip to content

Commit

Permalink
Migrate from analytics.js to gtag.js (#1720)
Browse files Browse the repository at this point in the history
  • Loading branch information
ballPointPenguin committed Oct 11, 2023
1 parent 53022ca commit b88a267
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions client-participation/public/index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,18 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Polis</title>

<!-- Google tag (gtag.js) -->
<% if (gaTrackingId) { %>
<script async src="https://www.googletagmanager.com/gtag/js?id=<%= gaTrackingId %>"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '<%= gaTrackingId %>');
</script>
<% } %>

<!-- REPLACE_THIS_WITH_FB_META_TAGS -->

<link rel="stylesheet" type="text/css" href="/css/polis.css"> <!-- proxy all CSS through server for respond.js -->
Expand Down Expand Up @@ -259,19 +271,5 @@
document.getElementsByTagName("body")[0].setAttribute("lang", ui_lang);
}
</script>

<% if (gaTrackingId) { %>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', '<%= gaTrackingId %>', 'auto');
ga('require', 'displayfeatures');
ga('send', 'pageview');
</script>
<% } %>

</body>
</html>

0 comments on commit b88a267

Please sign in to comment.