Managing Tag Templates

Managing Tag Templates

by Community Manager ‎01-31-2018 12:25 PM - edited ‎02-08-2018 03:42 PM (1,179 Views)

This article describes how tag templates work and how to update to the latest versions of vendor tag templates.

In this article:

Table of Contents Placeholder

What is a tag template?

Tag templates contain the JavaScript code that runs each vendor tag. Each tag has its own template that converts the tag configuration, data mappings, and extensions from the iQ interface into JavaScript code that runs on your site.

How can I use tag templates?

There are a number of scenarios where you might need to use a tag template, including:

  • Updating to a newer version of a tag
  • Customizing the core functionality of a tag
  • Fixing a bug in a tag

Some customizations and fixes can be achieved using an extension scoped to the tag. This approach should be explored first because it is easier to maintain and integrate into the publish workflow.

Do I need to update?

Tag vendors are constantly updating their technologies. When a vendor releases a major update to their tag, the Tag Marketplace will also be updated so you can take advantage of their new features. To check the status of your tags to determine if you need to update, use the Tag Status Checker.

Is it safe to update?

When the tag template has not been altered, the Tag Status Checker will indicate this using a 'Not Customized' symbol, a green dot as shown below: 
TagStatusChecker1.png
For tag templates that are not customized, a tag template update is a perfectly safe operation. However, when a tag templates is customized, the customizations are not carried over into the updated tag template. In these cases an evaluation is required to determine if the customized code needs to be applied to the upgraded tag template. That evaluation process is outside the scope of this article.

Version Template vs. Profile Template

In the edit template screen you have two options when saving your changes: Save Version Template and Save Profile Template. It is important to understand the difference between these two options so that you can avoid publishing code accidentally. In both options, saving changes to a tag template occurs immediately and does not require the profile to be saved.

tag-templates-version-vs-profile.png

Profile Template

A profile template is the default template for a tag in your iQ profile. Changes to the profile template will exist in all versions of the profile. You make changes to the profile template by clicking Save Profile Template in the tag template window. Regardless of which version of the profile you are in when you click Save Profile Template, the next time the profile is published it will include the modified tag template. However, the profile template is ignored if a version template exists.

The profile template is identified in the edit template screen with the suffix "(Profile)" in the name.

TemplateConfigProfileSelection.png

Version Template

A version template is a second, higher precedent version of the tag template. If a profile version contains a version template, it will take precedence over the profile template when the profile is published. Changes to the version template will only exist in the current version of the profile. You create and make changes to the version template by clicking Save Version Template in the tag template window. Once you create a version template, all subsequent profile versions will also have a version template.

The profile template is identified in the edit template screen with the suffix "(Version)" in the name.

The version template is the safest option when making tag template changes because it allows you to revert to a previous version of the template.

How do I update to the latest marketplace version?

In order to update a tag template to the latest version offered in the tag marketplace, you enter the tag template edit window and click the trash icon. This is called "dropping" the template. It deletes the current template and replaces it with the most current template from the marketplace. This action of "dropping" a template can also be used to revert a customized template back to the original.

Tag Template Scenarios

The following table illustrates the state of the profile and version templates across versions and publishes of a profile. This table reflects the following sequence of actions:

  1. In "Version 01", do Save as to create "Version 02".
  2. In "Version 02", edit a tag template and do Save Version Template to create "VT-1.0".
  3. In "Version 02", save and publish. Template "VT-1.0" takes precedence and is published.
  4. In "Version 02", do Save as to create "Version 03". Notice that version template "VT-1.0" is carried forward to the new profile version.
  5. In "Version 03", do Save as to create "Version 04".
  6. In "Version 04", edit "VT-1.0" and click Save Version Template to create "VT-1.1".
  7. In "Version 04", save and publish. Template "VT-1.1" takes precedence and is published.
Profile Version Profile Template (PT) Version Template (VT) Publish
Version 04 PT-1.0 VT-1.1 VT-1.1
Version 03 PT-1.0 VT-1.0 VT-1.0
Version 02 PT-1.0 VT-1.0 VT-1.0
Version 01 PT-1.0 n/a PT-1.0

Now let's look at some actions you could take from here and see what the results would be.

Action: In "Version 04", edit the profile template and click Save Profile Template to create "PT-1.1".

Result: The updated profile template, "PT-1.1", will be accessible from any version of the profile. Only a publish from "Version 01" would result in "PT-1.1" being published.

Action: In "Version 04", drop the version template and save and publish.

Result: Version template "VT-1.1" would be deleted and "Version 04" would no longer have a version template. The published template would be "PT-1.0". Previous versions, "Version 03" and "Version 02", would still have a version template.

Updating a Tag Template

In this workflow you will introduce a version template to your profile, copy the existing profile template content into a version template to keep it as a backup, drop the profile template to get the latest marketplace version, then copy its contents into a second version template for testing.

The table below illustrates the expected state of your profile and templates upon completing these steps.

Profile Version Profile Template (PT) Version Template (VT) Publish
Version 03 AdWords New AdWords New AdWords New
Version 02 AdWords New AdWords Orig AdWords Orig
Version 01 AdWords New n/a AdWords Orig

To update a tag template to the latest marketplace version and retain a backup copy of the original tag template:

Create a Backup of Current Tag Template in Version Template

  1. Go to the Tags screen, find the tag to update, and click Edit Template. (See more about editing tag templates.)
    tagslist1.png
  2. Click Save Version Template and click Close.
  3. Perform a "Save as" and publish the profile, giving a title and description to identify the template update, such as "Backup tag template - Google Adwords".

Result:

Profile Version Profile Template (PT) Version Template (VT) Publish
Version 02 AdWords Orig AdWords Orig AdWords Orig
Version 01 AdWords Orig n/a AdWords Orig

Drop the Profile Template to Get the Latest Marketplace Version

  1. Go to the Tags screen, find the tag to update, and click Edit Template.
  2. In the pop-up window, select the profile template.
  3. Click the trash icon (1) and click Yes (2) to confirm the action, then click Close.

    Do not click Save Version Template or Save Profile Template during this step.

    DropTemplate2.png
  4. Perform a "Save as" and publish, giving a title and description to identify the template update, such as, "Upgrade tag template - Google Adwords": 
    SaveTaginProfile.png

Result:

Profile Version Profile Template (PT) Version Template (VT) Publish
Version 03 AdWords New AdWords Orig AdWords Orig
Version 02 AdWords New AdWords Orig AdWords Orig
Version 01 AdWords New n/a AdWords Orig

Save the New Profile Template Into the Version Template

  1. Go to the Tags screen, find the tag to update, and click Edit Template.
  2. In the pop-up window, select the profile template.
  3. Click Save Version Template, then click Close.
  4. Perform a "Save" and publish.

Result:

At this point the version template will be used. The new template is in "Version 03" and the older template is in "Version 02".

Profile Version Profile Template (PT) Version Template (VT) Publish
Version 03 AdWords New AdWords New AdWords New
Version 02 AdWords New AdWords Orig AdWords Orig
Version 01 AdWords New n/a AdWords Orig

Reverting to a Previous Version Template

To return to a previous version of the template:

  1. Opening the Version tab.
  2. Identify the previous version with the original tag template and switch to that versionVersionsForBackup.png
  3. Go to the Tags screen, find the tag to update, and click Edit Template.
  4. In the pop-up window, select the version template.
  5. Use Select All (PC: ctrl+a, Mac: cmd+a) and Copy (PC: ctrl+c, Mac: cmd+c) to copy the tag template contents from the window into the paste buffer. Then click Close.
  6. Click the Switch to the latest version link to reopen the latest published version.

    SwtichtoLatestPublishedVersion.png

  7. Go to the Tags screen, find the tag to update, and click Edit Template.
    In the pop-up window, select the version template.
  8. Use Select All and Paste (PC: ctrl+v, Mac: mcd+v) to paste the contents of your paste buffer into the window to update the contents of the tag template.
  9. Click Save Version Template and click Close.
  10. Save and publish the profile with a title and description to identify that you have returned to a back-up version of the tag template.

Result:

The original tag template, saved as the version template in "Version 02", has been copied and pasted into the version template of "Version 03" and republished.

Profile Version Profile Template (PT) Version Template (VT) Publish
Version 03 AdWords New AdWords Orig AdWords Orig
Version 02 AdWords New AdWords Orig AdWords Orig
Version 01 AdWords New n/a AdWords Orig