Created
April 30, 2014 14:39
-
-
Save braidn/11428931 to your computer and use it in GitHub Desktop.
Google Analytics Quarterly
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<% if tracker = Spree::Tracker.current %> | |
<script type="text/javascript" src="//www.googleadservices.com/pagead/conversion.js"></script> | |
<%= javascript_tag do %> | |
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ | |
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), | |
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) | |
})(window,document,'script','//www.google-analytics.com/analytics.js','ga'); | |
ga('create', '<%= tracker.analytics_id %>', 'quarterly.co'); | |
ga('send', 'pageview'); | |
<% if flash[:commerce_tracking] %> | |
<%#Sales Funnel from legacy application%> | |
<%# Custom Tracking %> | |
var src = <%=raw %Q{"HTTPS://bs.serving-sys.com/BurstingPipe/ActivityServer.bs?cn=as&ActivityID=#{contributor.gift_tracking_code}&rnd="} %> | |
var ebRand = Math.random()+''; | |
ebRand = ebRand * 1000000; | |
document.write('<scr'+'ipt src='+ src + ebRand +'></scr' + 'ipt>'); | |
$(function(){ | |
var loc = window.location, | |
dest = loc.pathname, | |
param = loc.search, | |
curator = dest.split('/products/')[1], | |
pattern = /gift/; | |
// Not using the History API for now | |
// console.log('loc') | |
// window.history.pushState('', '', dest); | |
if(param.match(pattern)){ | |
ga('send','event','user','gifted', curator); | |
} else { | |
ga('send', 'event', 'user', 'subscribed', curator); | |
} | |
}); | |
/* <![CDATA[ */ | |
var google_conversion_id = 999349433; | |
var google_conversion_language = "en"; | |
var google_conversion_format = "3"; | |
var google_conversion_color = "ffffff"; | |
var google_conversion_value = <%= params[:t].to_f %>; | |
var google_remarketing_only = false; | |
<% if params[:gift] %> | |
var google_conversion_label = "swJ6CMfclwkQubnD3AM"; | |
<% else %> | |
var google_conversion_label = "CKRMCIfViAkQubnD3AM"; | |
<% end -%> | |
/* ]]> */ | |
<% end %> | |
<%= yield :ga_tracking %> | |
<% end %> | |
<noscript> | |
<div style="display:inline;"> | |
<% if params[:gift] %> | |
<img height="1" width="1" style="border-style:none;" alt="" | |
src="//www.googleadservices.com/pagead/conversion/999349433/?value=<%= params[:t].to_f %>&label=swJ6CMfclwkQubnD3AM&guid=ON&script=0"/> | |
<% else %> | |
<img height="1" width="1" style="border-style:none;" alt="" | |
src="//www.googleadservices.com/pagead/conversion/999349433/?value=<%= params[:t].to_f %>&label=CKRMCIfViAkQubnD3AM&guid=ON&script=0"/> | |
<% end -%> | |
</div> | |
</noscript> | |
<% end %> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment