Skip to content

Instantly share code, notes, and snippets.

@33sticks
33sticks / dynamic_dtm_marketing_pixel.js
Last active January 18, 2016 17:21
A method for dynamically creating a marketing pixel using Adobe DTM.
if(_satellite.getVar('Order Value')){
var orderValue;
var img = new Image();
orderValue = _satellite.getVar('Order Value');
img.src = "https://marketingpixel.example.org/track/conv/?adid=2dngvjx&order_value=" + orderValue ;
document.body.appendChild(img);
}
@33sticks
33sticks / dtm_pixel_template.js
Last active April 18, 2016 14:20
A template to manage marketing tags/pixels in DTM with a date comparison to kill pixels that are outside of campaign flight dates.
//ACTION REQUIRED: TAG CONFIGURATION
var killDate = new Date("MM/DD/YYYY"); //INPUT CAMPAIGN END DATE
var vendorName = ""; //INPUT NAME OF MARKETING VENDOR
var requestNum = ""; //INPUT TRACKING REQUEST NUMBER
var tagName = ""; //INPUT NAME OF TAG/PIXEL
//Get current date and remove hours
var todaysDate = new Date();
todaysDate.setHours(0,0,0,0);
try {
if (window.dataLayer.page.attributes.length){
var refinements="";
for (var i = 0; i < window.dataLayer.page.attributes.length; i++) {
if (dataLayer.page.attributes[i].attributeInfo){
refinements += dataLayer.page.attributes[i].attributeInfo.refinementValue + ";";
}
}
for (var i = 0; i < dataLayer.cart.item.length; i++) {
s.products += ",;" + dataLayer.cart.item[i].productInfo.productID;
}
s.products = s.products.substr(1);
@33sticks
33sticks / gist:b459cbaa34862165d3869a8a629088b2
Created August 18, 2016 23:44
Adobe DTM: Process Payment Types Using a Case Statment
for (var i = 0; i < dataLayer.transaction.item.length; i++) {
var payType = dataLayer.transaction.total.paymentMethods[i].paymentMethod;
switch(payType) {
case "CREDIT_CARD":
s.eVar45 = dataLayer.transaction.total.paymentMethods[i].paymentMethod;
s.events += ",event27";
break;
case "PAYPAL":
for (var i = 0; i < dataLayer.event.length; i++) {
if(dataLayer.event[i].eventInfo.eventName == "Checkout"){
s.events += ",scCheckout";
break;
}
}
@33sticks
33sticks / Remove Report Comment Header
Last active October 26, 2016 14:56
This Python script will remove the comment header from a downloaded Adobe Analytics report
#import the pandas library
import pandas as pd
#pull adobe report download into a dataframe; ignorning the comment header
df = pd.read_csv("/Users/jasonthompson/Documents/analysis/python/sp/adobe_id.csv", comment="#", header=1)
#export cleaned data to a new csv file
df.to_csv("/Users/jasonthompson/Documents/analysis/python/sp/adobe_id_no-comments.csv", encoding='utf-8')
/*YouTube Player updates required by Adobe Video Tracking module */
var n=0;
jQuery('iframe').each(function() {
var src = jQuery(this).attr('src');
if(src){
if (src.indexOf('youtube.com') > -1) {
@33sticks
33sticks / gist:cd1aa964bd9d5ca8bdd68d5fc6dec206
Created October 28, 2016 18:06
Adobe Analytics Media Module
/*
* Media Module
*/
function AppMeasurement_Module_Media(q){var
b=this;b.s=q;q=window;q.s_c_in||(q.s_c_il=[],q.s_c_in=0);b._il=q.s_c_il;b._in=q.s_c_in;b._il[b._in]
=b;q.s_c_in++;b._c="s_m";b.list=[];b.open=function(d,c,e,k){var f={},a=new Date,l="",g;c||(c=-
1);if(d&&e){b.list||(b.list={});b.list[d]&&b.close(d);k&&k.id&&(l=k.id);if(l)for(g in
b.list)!Object.prototype[g]&&b.list[g]&&b.list[g].R==l&&b.close(b.list[g].name);f.name=d;f.length=c
;f.offset=0;f.e=0;f.playerName=b.playerName?b.playerName:e;f.R=l;f.C=0;f.a=0;f.timestamp=
Math.floor(a.getTime()/1E3);f.k=0;f.u=f.timestamp;f.c=-1;f.n="";f.g=-
/* YouTube Player Mapping (https://developers.google.com/youtube/iframe_api_reference) */
var playerInfoList=new Array();
$("[id^='player']").each(function(){
var player=$(this).attr('id');
playerInfoList.push(player);
});
var players=new Array();
window.onYouTubeIframeAPIReady = function() {
for(x=0;x<playerInfoList.length;x++){
players[x] = new YT.Player(playerInfoList[x], {