Start guide
›
js library
›
How to place tag snippets using Google Tag Manager (GTM)
By placing customized tags even when coordinating with GTM, you can change the following information.
This section explains how to send the above information data from sites that use CODE Marketing cloud to GTM and how to send applicable data from GTM to CODE Marketing cloud.
1. Send measured data to GTM
1-1. Determine the page you want to measure and the information to measure
Make sure the page where you want to place customized tags is only a page where you want to measure various information.
1-2. Send measured information from the applicable page to GTM
In the page determined in 1-1, insert the following type of tag snippets in the location where you want to measure data.
<script>
var dataLayer = dataLayer || [];
dataLayer.push({
"event": "track:memberUpdateEvent",
"gender" : "Male",
"lastName" : "Taro",
"firstName": "Example"
});
</script>
Remember that the above samples are for Member attribute measurement If you want to measure other information, change the following points based on the above samples.
- The
event variable is used for recognizing custom events in GTM,so it is not possible to change the variable name . We recommend entering values associated with the information you want to measure from the track list found in “js library” just as with track:memberUpdateEvent.
-Variables such as gender, lastName, firstName are used when sending data from GTM to CODE Marketing cloud. Change these according to the variables required by each type of information to be measured. Also, because the values set in each variable for the above tag snippets are samples, so they should be changed as appropriate. Make sure to place tags in locations where each value can be accurately referred to so that CODE Marketing cloud can operate correctly.
※ Note that dataLayer is an object available in GTM and is used to hand over information to GTM. For dataLayer details, see the following webpage.
The data layer - Tag Manager Help
2. Send applicable data from GTM to CODE Marketing cloud
2-1. Register the dataLayer variable to GTM
Register the variable set in “1-2. Send measured information from the applicable page to GTM” to GTM.


2-1-2. For the variable type, select “Page variables” > “Data layer variables”

2-1-4. Click Save

2-2. Create a trigger

2-2-2. In trigger type “Other”, select “Custom event”

2-2-3. In the trigger occurrence location, select “All custom events”
2-2-5. Click “Save”

2-3. Customize Data send to CODE Marketing cloud
2-3-1. In “Select tag type”, select “Custom HTML tag”
Refer to the following sample tags and help pages of each customized tag for information you want to measure when writing.
{{gender}},{{lastName}},{{firstName}} handle the variable names set in 2-1-3.. Take note that the description must contain {{}} .
<script>
_cc('track', 'memberUpdateEvent', {
gender: {{gender}},
name: {
last: "{{lastName}}",
first: "{{firstName}}",
}
});
</script>

2-3-3. Click “Advanced settings” and set the “Tag distribution priority” to “10”
※ Make sure to adjust the distribution priority value as appropriate for your site.
2-3-4. In “Distribution timing”, specify the trigger created in “2-2. Create a trigger”
2-3-5. Click “Save”
2-4. “Publish” changes
Publishing applies changes to your website for the first time.

Reference: Basic explanation on customized tags
CODE Marketing cloud Start Guide - “js library”