Skip to content

Instantly share code, notes, and snippets.

@wmcraver
Created April 6, 2017 22:45
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/108df42afb1277ebcfa41135230da0a0 to your computer and use it in GitHub Desktop.
Save wmcraver/108df42afb1277ebcfa41135230da0a0 to your computer and use it in GitHub Desktop.
Tealium Extension - capitalize first letter of each word in string
// b.channel = b.channel // The data layer value goes here. Should look like: one two three.
channelSplit = b.channel.split(" ");
for (i = 0; i < channelSplit.length; i++) {
channelSplit[i] = channelSplit[i].substring(0,1).toUpperCase() + channelSplit[i].substring(1,channelSplit[i].length);
}
b.channel = channelSplit.join(" "); // Change sectionName to the data layer variable. should look like: One Two Three.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment