Skip to content

Instantly share code, notes, and snippets.

@wmcraver
Created January 17, 2017 00:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wmcraver/3b24c3cb080648479c45c5c3aab97586 to your computer and use it in GitHub Desktop.
Save wmcraver/3b24c3cb080648479c45c5c3aab97586 to your computer and use it in GitHub Desktop.
Javascript extension for Tealium to capitalize the first letter of a section name so that they are consistent in the system.
sectionName = "word word word"; // The data layer value goes here. Should look like: best western rewards.
sectionNameSplit = sectionName.split(" "); // Split the sectionName into an array -- separator is a space.
for (i = 0; i < sectionNameSplit.length; i++) {
sectionNameSplit[i] = sectionNameSplit[i].substring(0,1).toUpperCase() + sectionNameSplit[i].substring(1,sectionNameSplit[i].length);
}
sectionName = sectionNameSplit.join(" "); // "Word Word Word" stored back in sectionName
// Change sectionName to value being sent to Analytics system from Tealium.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment