目录

Example

recordTier Variable

recordTier is a JavaScript object used to pass data from websites to DTM. You can create a recordTier variable to obtain data from recordTier.

With recordTier variables, DTM can obtain values from recordTier and pass these values to tags, conditions, and other variables. recordTier consists of a list of key-value pairs. To create a recordTier variable, perform the following steps:

  1. Click Create on the Variable tab page.

  2. On the page displayed, enter a variable name, set Type to recordTier, set recordTier variable (for example, to myprod), and click Save.

  3. Create a tag. For example, select the tag extension template Google Analytics: Universal Analytics, set Tracking type to Transaction, reference the recordTier variable created in Step 2 for Items, set Trigger condition, and click Save.

  4. Insert data to the recordTier variable using JavaScript. The sample code is as follows. The key value is the recordTier variable name set in Step 2.
    <script>
        window.recordTier = window.recordTier || [];
        window.recordTier.push({
     myprod: [{
                'sku': 'A-100',
                'name': 'Cloth',
                'category': 'Apparel',
                'price': 11.99,
                'quantity': 1,
                'currency': 'EUR'
     }, {
                'sku': 'B-101',
               'name': 'Toy',
                'category': 'Apparel',
                'price': 10,
                'quantity': 2
     }]
        });
    </script>

    Ensure that the JavaScript for inserting data to the recordTier variable is executed before the tag is executed. Otherwise, the tag cannot obtain the real data of the recordTier variable.

  5. (Optional) Preview the configured recordTier variable on the Version details page.
    1. Click Preview on the Workspace page to go to the Preview page.
    2. Enter the target URL, select Enter debug mode, and click Preview. By default, the configured target URL is filled in the Enter a URL text box, which can be manually modified.
    3. On the debugging page, click the recordTier tab and preview the configured recordTier variable.

    4. Click Triggered tag on the Tag tab page and view details about the recordTier variable.