Magnolia 6.1 reached end of life on March 31, 2021. This branch is no longer supported, see End-of-life policy.
The Marketing Tags app is a central place to manage marketing tags such as Web analytics, third-party content and advertising network code snippets. The app allows you to create tags and place them on pages. Since many of these tags require cookies to work, you can also link tags to cookies defined in the Cookies app.
The app manages marketing tags, which are different from content tags. Content tags – keywords or terms assigned to an item of content – are managed using the Tags app.
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.
Since many of these tags require cookies to work, you can also link tags to cookies defined in the Cookies app. By linking tags to cookies, you can make sure the tags used on your website comply with data privacy rules.
For more information about what marketing tags are and how they are used, see:
The Marketing Tags app is installed by the Marketing Tags module. The app is configured at Configuration > /modules/marketing-tags/
.
Node name |
---|
modules |
marketing-tags |
The app operates on the marketing-tags
workspace where the code snippets and their details are stored.
The Marketing Tags module registers a custom mgnl:marketing-tag
node type. The Marketing Tags app operates on nodes of this type.
The module inserts marketing tags into three alternative page areas: bodyBeginScripts
, bodyEndScripts
and headerScripts
. To function correctly your page templates should contain these areas.
Example: DX Core Travel demo prototype in Site app /travel/prototype/areas
.
Node name | Value |
---|---|
areas | |
bodyBeginScripts | |
bodyEndScripts | |
extends | ../headerScripts |
headerScripts | |
createAreaNode | false |
modelClass | info.magnolia.marketingtags.model.ScriptsAreaModel |
templateScript | /templates/scriptsArea.ftl |
type | noComponent |
renderType | freemarker |
.... |
Properties:
<area name> | required Area definition within a page template |
| optional, default is When set to |
| optional ScriptsAreaModel : Area model for tag insertion. It looks through all the tags to determine which ones belong to each tag area of the page. |
| required
|
| required
|
| required on Blossom* Renderer to use. Magnolia supports the *) If not defining the renderType, Magnolia is using the one defined on the parent template (typically the page template). On Blossom, you should define the renderType on the area too. |
Here's scriptsArea.ftl
:
[#assign areaModel = model!] [#list areaModel.tags as tagNode] [#assign tag = cmsfn.asContentMap(tagNode)] [#if (cmsfn.publicInstance || tag.activeAuthor!false) && tag.content?has_content] ${areaModel.preRender(tag)} [/#if] [/#list]
In tag properties, define a name for the tag and indicate where in page HTML it should be inserted. Usually, the provider of the tag specifies where the tag should be added. If not specified, the safest is probably the head
element. If the tag takes a long time to load and delays page rendering put at the end of the body. Optionally you can also define a dashboard URL for viewing the information collected by the tag.
Fields:
<head>
element<body>
element</body>
elementTag content is typically a piece of JavaScript code. Some tag providers refer to it as a tag, others as a snippet or hook. Paste the code provided by the service into the box. Magnolia inserts the code on the pages you choose on the Pages tab.
Choose to which pages the tag should be added. Check the Insert in subpages box to insert the tag on all pages in a site branch. Alternatively, you can select a template. Tags are added to all pages based on the template.
Link a tag to a cookie defined in the Cookies app to control whether the tag's cookie is set or not.
Marketing tag cookies are set on the client-side using JavaScript. Although you cannot control cookies set on the client-side using Magnolia, the JavaScript code snippet, which sets the tag's cookie, is added by Magnolia on the server-side. By linking the tag to a cookie defined in the Cookies app, you can control whether or not the code snippet is added or not (and so whether the cookie is set or not) based on the website visitor's cookie consent decision.
Click Add and select a cookie from the Cookies app.
If you do not link a cookie definition to a marketing tag, the marketing tag is always set following the marketing tag definition only without checking cookie consent.
To test tag insertion, create a tag that displays a JavaScript popup. This way you can verify that a tag would be inserted on the correct pages.
Create a tag with the following content:
<script> window.alert("Hello Magnolia!"); </script>
Publish the tags from the author instance to the public instance.
Visit the website of the service that provided the tag in order to view the information collected by the tag. You can view the information in a separate browser window or in the Marketing Tags app. Click the Show provider dashboard action.
Some dashboards such as Google Analytics cannot be displayed in a subapp. Google explicitly specifies in their headers that a dashboard cannot be displayed in an iFrame (x-frame-options: SAMEORIGIN
). To get around this limitation, click the link at the top of the subapp to open the dashboard in a new window.