Skip to content

Instantly share code, notes, and snippets.

@padicode
padicode / gist:4731996
Last active December 12, 2015 06:49
dataLayer example for Google Tag Manager
dataLayer = [{
'page': 'search',
'searchedKeyword': 'rc car',
'visitorType': 'high-value',
'nrDisplayedResults': '70',
'appliedFilters': [ 'price' : '<10' , 'color' : 'red' ], //applied filters
'nrAvailableFilters': '4', // number of available filters
'priceRanges': [ '0-10$' : '23' , '11$-49$' : '2' , '50$-99$' : '45' ], //pricing range of products
'searchCategory': 'boyToys',
'productReviews': [ '0 reviews' : '68' , 'positive reviews' : '0' , 'negative reviews' : '2' ]
@padicode
padicode / gist:5066547
Last active December 14, 2015 09:38
JavaScript hooks for PadiAct actions
<script type="text/javascript">
window.nrlskOnEvent = function(padiact)
{
if (padiact.type=='open')
{
// the code that needs to run when the PadiAct pop-up is displayed goes here
// example:
console.log ('PadiAct Showed Up');
// available vars:
// padiact.id (padiact campaign ID)
@padicode
padicode / gist:5245976
Created March 26, 2013 14:54
Custom PadiAct Action Template
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title></title>
<style>
#padiact_overlay_div
{ }
@padicode
padicode / gist:5318565
Created April 5, 2013 11:21
Google Analytics Universal Tracking Init in Google Tag Manager
<script>
(function(q,u,i,c,k){window['GoogleAnalyticsObject']=q;
window[q]=window[q]||function(){(window[q].q=window[q].q||[]).push(arguments)},
window[q].l=1*new Date();c=i.createElement(u),k=i.getElementsByTagName(u)[0];
c.async=true;c.src='//www.google-analytics.com/analytics.js';
k.parentNode.insertBefore(c,k)})('ga','script',document);
ga('create', 'UA-XXXXXXXX-XX', 'yourwebsite.com'); //make sure to customize your tracking ID and your domainname
dataLayer.push({"event":"trackingLoaded"}); //don't forget to add this line
@padicode
padicode / gist:5318608
Last active April 6, 2020 16:04
Reader vs Scanner behavior
<script>
/*
The original script for the current Google Analytics tracking code is provided by Justin Cutroni: http://cutroni.com/blog/2012/02/21/advanced-content-tracking-with-google-analytics-part-1/
I modified the script to make it work with the new analytics.js - Universal Analytics that Google Analytics is due to launch in 2013.
I also added minor changes to the logic. Any suggestions for optimization are welcomed.
*/
jQuery(function($) {
// Debug flag
var debugMode = false;
@padicode
padicode / gist:5364916
Last active December 16, 2015 02:49 — forked from anonymous/gist:5318836
<script>
if ({{pageName}} == 'article')
{
//set the dimension id that is set inside Google Analytics for each dimension
ga('set', 'dimension1', {{postCategory}});
ga('set', 'dimension3', {{postTitle}});
ga('set', 'dimension4', {{postType}});
}
if ({{pageName}} == 'archive')
{
@padicode
padicode / gist:5388363
Created April 15, 2013 14:13
Referrer Tracking Axa
function createCookie(e,t,n){if(n){var r=new Date;r.setTime(r.getTime()+n*24*60*60*1e3);var i="; expires="+r.toGMTString()}else var i="";document.cookie=e+"="+t+i+";domain=.axa-asigurari.ro; path=/"}function readCookie(e){var t=e+"=";var n=document.cookie.split(";");for(var r=0;r<n.length;r++){var i=n[r];while(i.charAt(0)==" ")i=i.substring(1,i.length);if(i.indexOf(t)==0)return i.substring(t.length,i.length)}return null}function googleCookieReferrer(){var e=readCookie("__utmz");if(e.indexOf("utmcsr")==-1)return null;if(e!=null){if(e.indexOf("%7C")!=-1){e=e.split("%7C");e=e[0].split("%3D")}else{e=e.split("|");e=e[0].split("=")}if(e[1]!=""){return e[1]}else{return""}}else return""}var referer=googleCookieReferrer();if(referer!=null&&referer!=""){if(readCookie("__rfrr")){var feed=readCookie("__rfrr");var feed_temp=feed;var check="";feed=feed.split("|");if(feed[feed.length-1]==null){check=feed}else{check=feed[feed.length-1]}if(check!=referer)createCookie("__rfrr",feed_temp+"|"+referer,1e3)}else createCookie("__rf
@padicode
padicode / gist:5734456
Last active December 18, 2015 05:39
PadiAct Redirect on Subscribe
<script type="text/javascript">
window.nrlskOnEvent = function(padiact)
{
if (padiact.type=='subscribe')
{
window.location = "http://yourwebsite.com/newpage.html";
//change http://yourwebsite.com/newpage.html to the page you want to redirect when people subscribe
}
}
</script>
@padicode
padicode / gist:6115479
Last active December 20, 2015 10:30
PadiAct Subscribe JavaScript Hook
<script type="text/javascript">
window.nrlskOnEvent = function(padiact)
{
if (padiact.type=='subscribe')
{
// here should go the code that you want PadiAct to trigger when somebody subscribes
// the email address of the subscriber is available and url encoded: e.g. user%40gmail.com
// example:
console.log (padiact.email+' subscribed through PadiAct');
// available vars:
@padicode
padicode / gist:6761479
Last active December 24, 2015 07:09
PadiAct Naked Action HTML
<div class="padiOverlay" style="display: block;">
<div class="padiPop4Wrap" style="display: block;">
<div class="padiPop4Overlay" >
<div class="padiPopupContent" > <a href="#" class="padiClose" title="Close" style="display:block;" >&times;</a>
<div class="padiContent" style="display:block">
<h1 class="padiTitle">
<!-- any TEXT can go from here -->