Skip to content

Instantly share code, notes, and snippets.

@tygavin
tygavin / tealium_track_in_utag_beta
Created August 17, 2021 16:59
tealium.track support can be added as a JS Preloader Extension (or via utag 4.49 beta template)
// This code added just below "##UTLOADEXTENSIONS##" at the top of the template
(function(){
var w = window,
t = w.TEALIUM_GLOBAL = w.TEALIUM_GLOBAL || "##UTTEALIUMGLOBAL##".replace("##" + "UTTEALIUMGLOBAL##","") || "tealium",
q = function(){w[t].q.push(arguments)};
// Confirm the page is using new page code that defines tealium.track
if (w[t] && w[t].track && w[t].config) {
// No default page view event. Requires a tealium.track call
@tygavin
tygavin / node_js_extract_large_tar_bz.js
Created January 10, 2020 19:06
Streaming extract of huge tar.bz file
/*
* Author: Ty Gavin
* Date: 12/19/2019
*
* Summary
* The goal of this script is to extract a large .tar.bz file that contains text files (50GB+)
*
* Example: Use native bunzip2 and then pipe/stream output from this to this node program
* # bunzip2 -c < file.tar.bz | node extract_from_tar_bz_file.js
*
@tygavin
tygavin / amazon_alexa_hello_world_with_tealium.js
Created November 4, 2019 19:07
Alexa Skill example send event to and retrieve visitor (user) attributes from Tealium.
// IMPORTANT:
// Please update the ##ACCOUNT## and ##PROFILE## values below to match your Tealium account and profile names
// Most of the code below is the "Hello World" script provided by Amazon in the Alexa Developer Console
// This sample demonstrates handling intents from an Alexa skill using the Alexa Skills Kit SDK (v2).
// Please visit https://alexa.design/cookbook for additional examples on implementing slots, dialog management,
// session persistence, api calls, and more.
const Alexa = require('ask-sdk-core');
const https = require('https');
@tygavin
tygavin / amazon_alexa_skill_sample
Last active November 4, 2019 18:41
Shows how to call tealium.track inside and Amazon Alexa skill
// IMPORTANT:
// Please update the ##ACCOUNT## and ##PROFILE## values below to match your Tealium account and profile names
// This sample demonstrates handling intents from an Alexa skill using the Alexa Skills Kit SDK (v2).
// Please visit https://alexa.design/cookbook for additional examples on implementing slots, dialog management,
// session persistence, api calls, and more.
const Alexa = require('ask-sdk-core');
const https = require('https');
const crypto = require('crypto');
const hash = crypto.createHash('sha256');
@tygavin
tygavin / tealium_track_queue_with_utag.js
Last active August 17, 2021 17:00
Leverage tealium.track function and queuing support with utag.js implementation.
/*
* Summary: Wrapper adds support for tealium.track function and queuing events before utag.js is loaded.
* In addition, all tags will fire for every event (uses utag.view behind the scenes). You can control
* what tags fire with load rules. For the vendors with specific behavior for utag.link, see below.
*
* NOTE:
* - Page code below is inserted in html source while JavaScript is added to utag.js Preloader Extension
*
* - If the data layer includes a custom attribute that matches the name of what is defined in
* window.utag_cfg_ovrd.link_attribute, then utag.link is called, otherwise, utag.view is called.
@tygavin
tygavin / tealium_visitor_id_in_local_storage.js
Last active October 14, 2019 19:43
Stores a copy of tealium_visitor_id in local storage
/*
*
* Summary: Copies Tealium visitor id cookie value to localStorage to create a more
* durable anonymous visitor id.
*
* Requirements:
* - This localStorage value will not be updated until the 1 year point
* - This JS Code below is copy/pasted to a JavaScript Extension in Tealium iQ
* with an "All Tags" scope
*