Google Tag Manager
Google Tag Manager is a free tool that manages marketing tags in marketing applications. Once configured in Sitecore Content Hub™, various information from Content Hub can be shared with other applications (for example, Analytics) through Google Tag Manager.
Activation
To start using Google Tag Manager with Content Hub, you need to add the container ID of your Google Tag Manager to the key field in Google Tag Manager configuration in Settings.
Note
To get the container id, log into your Google Tag Manager account and find the container id located on the top right side of the user interface.
Events
Content Hub automatically sends information about specific events and actions to Google Tag Manager.
Name | Event data | Triggering action |
---|---|---|
Changelifecycle |
| Change the status of an entity (approve or reject). |
Delete |
| Delete an entity. |
Download |
| Download an asset (one of the available renditions). |
Draft |
| Create draft action on an entity. |
Edit |
| Save changes after editing an entity/portal page. |
Facet |
| Add a facet filter. |
Fulltextsearch |
| Perform a full-text search. |
Order |
| The download order request is successful (status code: 201). |
Pagesize |
| Set the page size in the paging menu. |
| Go to first page. | |
| Go to previous page. | |
| Go to next page. | |
| Go to last page. | |
Pageview |
| Load a new page (any page). |
Paging |
| Jump to a page. |
Preview |
| Preview an asset. |
Publish |
| Publish a theme or a portal version. |
Querybuilder |
| Perform a query builder search. |
Rating |
| Save the user score (after rating an entity). |
Search |
| Perform a search. |
Showmorefacets |
| Get all facet values. |
| Click on show more facets. | |
Sorting |
| Perform a data sorting. |
Upload |
| Upload a new file. |
Note
All the events have an additional dynamic parameter named options
that contains the page options and that is used for deriving the page name. For an example configuration file, see GTM-workspace-M-Events.json.
Analytics
If you want to send information about custom actions/events to Google Tag Manager, you can use the Analytics.log()
method built into Content Hub, or you can use window.dataLayer.push()
. Whichever you use, the code should be added to the external component.
For example, using Analytics.log()
:
Analytics.log = function (eventName, eventData, options) { ... }
In this example:
eventName
: the event name, written lowercase and without any spaces.eventData
: array of extra information or data you want to include for this event.options
: page options, which are optional and are used for deriving the page name.
Alternatively, you can use window.dataLayer.push()
, as shown in this example:
window.dataLayer.push({
'event': 'eventName',
'data1': 'eventData1',
'data2': 'eventData2'
});
For more information about using window.dataLayer.push()
, see The data layer on Google Developers.
Example: Lock event
The Lock event contains the id
of the entity and the entity definition name. It also contains the page name the action is triggered from because this information is derived from the options.
Analytics.log("lock", { id: entity.systemProperties.id(), definition: entity.definition.name }, options);
Example: ChangeLifeCycle
The change life cycle event occurs upon approval or rejection. The event contains the entity's id, the definition name, and the lifecycle, for example, approve or reject and so on.
The page name is derived from the options parameter.
Analytics.log("changelifecycle", { id: sentity.systemProperties.id(), definition: sentity.definition.name, lifecycle: config.lifeCycle }, options);
Can we improve this article ? Provide feedback