Created
August 2, 2012 14:06
-
-
Save tomfuertes/3237334 to your computer and use it in GitHub Desktop.
Base Tag Restructuring Pending Bootstrapper.bindDomParsed
This file contains hidden or 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
| (function () { | |
| var cdn = document.createElement('script'); | |
| cdn.type = 'text/javascript'; | |
| cdn.async = true; | |
| cdn.src = '//sub.domain.com/shared/bootstrap/0.8.0.2/js/libs/gas-utils.js'; | |
| var s = document.getElementsByTagName('script')[0]; | |
| s.parentNode.insertBefore(cdn, s); | |
| })(); | |
| (function () { | |
| webPropertyId = []; | |
| domain = []; | |
| siteId = []; | |
| webPropertyId[0] = 'UA-XXXXXX-1'; | |
| webPropertyId[1] = 'UA-XXXXXX-1'; | |
| domain[0] = 'domain.com'; | |
| domain[1] = 'example.com'; | |
| siteId[0] = ''; | |
| siteId[1] = ''; | |
| window.analyticsdatalayer = window.analyticsdatalayer || {}; | |
| window._gas = window._gas || []; | |
| var j = 0; | |
| var accountSet = false; | |
| for (i = 0; i < domain.length; i++) { | |
| if ((siteId[i] != '') && (document.getElementsByTagName('html')[0].id == siteId[i])) { | |
| _gas.push(['_setAccount', webPropertyId[i]]); | |
| accountSet = true; | |
| } | |
| _gas.push(['_setDomainName', domain[i]]); | |
| } | |
| if (!accountSet) { | |
| for (i = 0; i < domain.length; i++) { | |
| if ((webPropertyId[i] != '') && (location.hostname.indexOf(domain[i]) != -1)) { | |
| _gas.push(['_setAccount', webPropertyId[i]]); | |
| } | |
| } | |
| } | |
| for (i = 0; i < domain.length; i++) { | |
| if (location.hostname.indexOf(domain[i]) != -1) { | |
| j = i; | |
| } | |
| } | |
| /* ... SNIP ... */ | |
| function jqDependants() { | |
| if ((jQuery('meta[name="contrk"]').attr('content')) !== undefined) { | |
| canonical = (jQuery('meta[name="contrk"]').attr('content')); | |
| _gas.push(['_setCustomVar', 21, 'Canonical', canonical, 3]); | |
| } | |
| _gas.push(['_trackPageview']); | |
| var isOverGoogleAd = false; | |
| jQuery('iframe[src*="ad.doubleclick.net"]').mouseover(function () { | |
| isOverGoogleAd = true; | |
| }).mouseout(function () { | |
| isOverGoogleAd = false; | |
| }); | |
| jQuery(window).blur(function () { | |
| if (isOverGoogleAd) { | |
| _gas.push(['_setCustomVar', 18, 'AdSense Clicked', 'clicked', 2]); | |
| _gas.push(['_trackEvent', 'AdSense', 'clicked', analyticsdatalayer.pagename]); | |
| } | |
| }); | |
| jQuery('a[href*="icid"]').click(function () { | |
| regex = new RegExp('[?&]icid=([^&]*)'); | |
| icid = jQuery(this).attr('href').match(regex); | |
| _gas.push(['_setCustomVar', 19, 'Internal Promotion', icid[1], 2]); | |
| _gas.push(['_trackEvent', 'Internal Promotion', 'clicked', icid[1]]); | |
| }); | |
| } | |
| if (typeof jQuery == "undefined") { | |
| Bootstrapper.bindDomParsed(function () { | |
| jqDependants(); | |
| }); | |
| } else { | |
| jqDependants(); | |
| } | |
| })(); |
Author
Author
Wrapping jQuery Dependencies: https://gist.github.com/3237334/168bc4db49a65868f12223e9e12037bf2893a79f
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Initial Import: https://gist.github.com/3237334/7ca3e61077078d03c11c95509b86783e75a1ab17