40 hours of SEO Analysis Within Minutes!

Fast. Secure. Free.

The dataLayer is a critical part of GTM. Hence it is important that a standardised structure for naming of JSON objects and values is “set in concrete” at an early stage, as this will save significant time in QA testing. Also, JavaScript matching is case sensitive, thus using the wrong case will mean that no match is found, causing data discrepancies.

a) Capitalistation of variableNames

  1. camelCase e.g. “variableNameId” (GTM standard) [recommended]
  2. camelCase e.g. “variableNameID” (W3C standard)
  3. lowercase  e.g. “variablenameid” (Qubit & Adwords remarketing standard)

b) Capitalistation of values

  1. lowercase  e.g. “product name” or “/search?q=keyword” [recommended]
  2. camelCase e.g. “Product Name” or “/search?q=Keyword”

Note: capitalisation of value can be patched within GA using lowercase filters, but fixing the client-side code is recommended.

c) Encapsulation of text values

  1. double quotation marks e.g. “value” (W3C and RFC4627 standard) [recommended]
  2. single quotation marks e.g. ‘value’ (GTM standard)

Note1: it is not necessary to escape single quotes in productNames or categoryNames if these are encapsulated in double-quotes. For example

“transactionProducts”:[{ “name”: “11 heals”,   “category”: “Big Shoes” }],

Note2: for inline encapsulation single quotes should be used. For example:
<a href= “#” onclick=”dataLayer.push({‘event’: ‘value’});”>

Note3: it is recommended to encapsulation integers “1000” to remove risk of comma breaking ecommerce code: 1,000

e) Encapsulation of variableNames

  1. Quotation marks e.g. ‘variableName’ or “variableName” (GTM standard) [recommended]
  2. No encapsulation e.g. variableName, with exception of JS reserve words (W3C standard)

f) Separator for text values

  1. Dash g. “header-datalayer-loaded”
  2. Underscore g. “header_datalayer_loaded”
  3. Whitespace g. “blue shoes” (GTM ecommerce) [recommended]
  4. Plus g. “blue+shoes” (Gets converted to whitespace by GA)

g) Nesting

  1. no nesting e.g. transationId (transactionProducts.id exception) (GTM legacy)
  2. dots nesting e.g. ecommerce.purchase.actionField.id(GTM enhanced & W3C standard)
  3. underscore e.g. ecomm_pagetype, ecomm_prodid (Adwords Remarketing standard)

h) Language for international websites

It is recommended to default English with the foreign name added as a comment. For example:

  1. “variableNameId”: “value”; // Translation: Nom de la objet Id [recommended]
  2. “nomDeLaObjetId”: “value”; // Traduction: variableNameId

Tip: If a deployment has rolled-out with {{pageVirtual}}{{page_virtual}}{{pagevirtual}} it is possible to use simple patch within GTM to cobine these typos.

0117 3361103