Magnolia 5.6 reached end of life on June 25, 2020. This branch is no longer supported, see End-of-life policy.
A tag is typically a piece of JavaScript code. When a page loads, the JavaScript code runs and collects usage information about the page and the visitor. The tag then reports this information to the service that provided the tag. The service stores and analyses the information. If the service provides an analytics dashboard you can display it in the Marketing Tags app.
<dependency> <groupId>info.magnolia.marketingtags</groupId> <artifactId>magnolia-marketing-tags</artifactId> <version>1.3.1</version> </dependency>
Marketing Tags app allows editors to insert tags such as JavaScript code snippets for analytics engines into Web pages.
The Marketing Tags module is an Enterprise Edition module. If you work with the Community Edition you can include code snippets on your pages as resource files.
Include the code snippet as a resource file in your project.
<!-- Global site tag (gtag.js) - Google Analytics --> <script async src="https://www.googletagmanager.com/gtag/js?id=UA-1234567-2"></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'UA-1234567-2'); </script>
Use the Freemarker include
directive in your template script, as if you were referencing another script.
<head> [#include “/my-module/webresources/js/gtag.js"] </head>