Skip to content

Commit

Permalink
chore: add google analytics for user metrics collection
Browse files Browse the repository at this point in the history
  • Loading branch information
saladgg committed Sep 9, 2022
1 parent a030d47 commit 76d4b42
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 35 deletions.
34 changes: 0 additions & 34 deletions assets/static/js/project.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,37 +33,3 @@ function switchDashboards(event) {
// Hide the menu after selection
$("#accordionSidebar.toggled #dashboards-menu").removeClass("show");
}


(function($) {
/* Google Analytics */
window.dataLayer = window.dataLayer || [];

function gtag() {
dataLayer.push(arguments);
}
gtag("js", new Date());
gtag("config", "G-WW2W29ZMTZ");

// Auto-collapse open menus in responsive mode
$(".navbar-collapse a").click(function() {
$(".navbar-collapse").collapse("hide");
});

// Initialize the select2 plugin
$("select").each(function() {
$(this).select2({
allowClear: typeof $(this).data("allow-clear") !== "undefined" ? Boolean($(this).data("allow-clear")) : Boolean($(this).attr("multiple")),
closeOnSelect: !$(this).attr("multiple"),
placeholder: typeof $(this).data("placeholder") !== "undefined" ? $(this).data("placeholder") : {"id": `select2__placeholder__id__{$(this).attr('id')}`, "placeholder": `Select ${getElementLabelText(this)}`},
theme: "bootstrap4",
width: $(this).data("width") ? $(this).data("width") : $(this).hasClass("w-100") ? "100%" : "resolve",
});
});

// Initialize the date picker plugin
$(".datepicker").datepicker();

// Add a dashboard selection change listener
$("#dashboards-menu > div > a").click(switchDashboards);
})(jQuery);
15 changes: 14 additions & 1 deletion assets/templates/atoms/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,20 @@
<script defer src="{% static 'js/sb-admin-2.min.js' %}"></script>
<script defer src="{% static 'js/project.min.js' %}"></script>
{% endcompress %}
<script async src="https://www.googletagmanager.com/gtag/js?id=G-WW2W29ZMTZ"></script>

<script src="https://kit.fontawesome.com/e1c9d8c99d.js" crossorigin="anonymous"></script>
{% endblock javascript %}


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

gtag('config', 'G-S5JLWM36RQ');
</script>


</head>

0 comments on commit 76d4b42

Please sign in to comment.