Skip to content

Instantly share code, notes, and snippets.

@chrislpatton
Last active September 13, 2018 15:58
Show Gist options
  • Save chrislpatton/cc2cade404a86e3773efbf2ada2dbe17 to your computer and use it in GitHub Desktop.
Save chrislpatton/cc2cade404a86e3773efbf2ada2dbe17 to your computer and use it in GitHub Desktop.

Revisions

  1. chrislpatton revised this gist Sep 13, 2018. 1 changed file with 101 additions and 1 deletion.
    102 changes: 101 additions & 1 deletion analytics.html
    Original file line number Diff line number Diff line change
    @@ -74,4 +74,104 @@
    }
    var pageTracker = new trackEcommerce();
    </script>
    <script src="https://conduit.mailchimpapp.com/js/
    <script src="https://conduit.mailchimpapp.com/js/stores/ruomlrv671/conduit.js"></script>
    <script type="text/javascript">
    var _caq = _caq || [];
    (function () {
    var ca = document.createElement("script");
    ca.type = "text/javascript";
    ca.async = true;
    ca.id = "_casrc";
    ca.src = "//t.channeladvisor.com/v2/12029885.js";
    var ca_script = document.getElementsByTagName("script")[0];
    ca_script.parentNode.insertBefore(ca, ca_script);
    })();
    </script>

    <!-- This is the bing conversion tracking script and style for checkout page -->

    <script>(function(w,d,t,r,u){var f,n,i;w[u]=w[u]||[],f=function(){var o={ti:"4030507"};o.q=w[u],w[u]=new UET(o),w[u].push("pageLoad")},n=d.createElement(t),n.src=r,n.async=1,n.onload=n.onreadystatechange=function(){var s=this.readyState;s&&s!=="loaded"&&s!=="complete"||(f(),n.onload=n.onreadystatechange=null)},i=d.getElementsByTagName(t)[0],i.parentNode.insertBefore(n,i)})(window,document,"script","//bat.bing.com/bat.js","uetq");</script>

     <script>
    window.uetq = window.uetq || [];
    window.uetq.push({ 'gv': %%ORDER_AMOUNT%% });
    </script>

    <!-- This is the custom script and style for checkout page -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
    <script>
    // check for ios device
    jQuery(window).load(function(){
    setTimeout(function(){
    jQuery(function(){
    jQuery('#FormField_11>option').each(function () {
    var countries = [ 'United States', 'Canada', 'Choose a Country' ];
    var country = jQuery(this).text();
    if (countries.indexOf(country) == -1) {
    jQuery(this).remove();
    }
    });
    jQuery('#FormField_21>option').each(function () {
    var countries = [ 'United States', 'Canada', 'Choose a Country' ];
    var country = jQuery(this).text();
    if (countries.indexOf(country) == -1) {
    jQuery(this).remove();
    }
    });
    jQuery('#FormField_11_select>option').each(function () {
    var countries = [ 'United States', 'Canada', 'Choose a Country' ];
    var country = jQuery(this).text();
    if (countries.indexOf(country) == -1) {
    jQuery(this).remove();
    }
    });
    jQuery('#FormField_21_select>option').each(function () {
    var countries = [ 'United States', 'Canada', 'Choose a Country' ];
    var country = jQuery(this).text();
    if (countries.indexOf(country) == -1) {
    jQuery(this).remove();
    }
    });
    jQuery('#shipping-country').html('<option value="">Choose a Country</option><option value="226">United States</option><option value="038">Canada</option>');
    });

    },1500);
    jQuery(document).ajaxSuccess(function() {
    setTimeout(function(){
    console.log('Every time ajax run success');
    jQuery('#FormField_21>option').each(function () {
    var countries = [ 'United States', 'Canada', 'Choose a Country' ];
    var country = jQuery(this).text();
    if (countries.indexOf(country) == -1) {
    jQuery(this).remove();
    }
    });
    jQuery('#FormField_11>option').each(function () {
    var countries = [ 'United States', 'Canada', 'Choose a Country' ];
    var country = jQuery(this).text();
    if (countries.indexOf(country) == -1) {
    jQuery(this).remove();
    }
    });
    jQuery('#billingAddress select option').each(function () {
    var countries = [ 'United States', 'Canada', 'Select a country...' ];
    var country = jQuery(this).text();
    var newcountry = country.replace(/(^\s+|\s+$)/g, '');
    console.log(newcountry);
    if (countries.indexOf(newcountry) == -1) {
    jQuery(this).remove();
    }
    });
    },1500);
    });
    setTimeout(function(){
    jQuery('.mobileMenu-toggle.is-open').click(function(){
    console.log('open menue clicked');
    });
    },1500);
    });
    </script>

    <style>
    #Header .header-logo{padding:20px 0;text-align:center}#Header .header-logo img{max-height:10em}.Block.ExpressCheckout .header-logo{padding:10px 0;text-align:center;margin-bottom:0}.Block.ExpressCheckout .header-logo img{max-height:8rem}#CheckoutStepAccountDetails .btn,.ExpressCheckoutBlock .step,.ExpressCheckoutContent .btn{background-color:#339b6a;border-color:#339b6a;color:#fff}#CheckoutStepAccountDetails .btn:hover,.ExpressCheckoutBlock .step:hover,.ExpressCheckoutContent .btn:hover{background-color:#b39b7b;border-color:#b39b7b;transition:.5s}#SearchForm input,.Block.ExpressCheckout dd,.Block.ExpressCheckout div,.Block.ExpressCheckout h4,.Block.ExpressCheckout p,.Block.ExpressCheckout span,.ExpressCheckoutBlockCollapsed .ExpressCheckoutTitle h3,input,input.Textbox,input[type=text],select,textarea{color:#000}.ExpressCheckoutBlock .ExpressCheckoutTitle .step{color:#fff}.Block.ExpressCheckout dd a{cursor:pointer}.footer-links>.inner p{text-align:center;color:#000}.previewCartCheckout-additionalCheckoutButtons{margin-top:3%}@media (max-width:1023px){#Header .header-logo{margin-bottom:0;padding:20px 0}#Header .header-logo img{max-height:100px;display:block;margin:0 auto}.ExpressCheckoutContent .HorizontalFormContainer dd{width:65%}.FloatLeft{float:none}.AccountLogin dd{width:100%!important}}@media (max-width:767px){.Content.ExpressCheckoutBlock .ProductActionAdd{display:block!important}.ExpressCheckoutContent .HorizontalFormContainer dd{width:100%}.FloatLeft{float:none}}@media (max-width:940px){.navBar.navBar--sub.navBar--account{display:block}}@media screen and (orientation:landscape) and (max-width:767px){.ProductList .ProductDetails{min-height:80px!important}}
    </style>
  2. chrislpatton created this gist Sep 13, 2018.
    77 changes: 77 additions & 0 deletions analytics.html
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,77 @@
    <meta name="google-site-verification" content="nozy74bN8-K65HpQcyEZ7cKESqxNeuLtQoVo_m42tNM" />

    <script type='text/javascript'>

    window._tfa = window._tfa || [];

    window._tfa.push({notify: 'event', name: 'page_view'});

    !function (t, f, a, x) {

    if (!document.getElementById(x)) {

    t.async = 1;t.src = a;t.id=x;f.parentNode.insertBefore(t, f);

    }

    }(document.createElement('script'),

    document.getElementsByTagName('script')[0],

    '//cdn.taboola.com/libtrc/unip/1142161/tfa.js',

    'tb_tfa_script');

    </script>

    <noscript>

    <img src='//trc.taboola.com/1142161/log/3/unip?en=page_view'

    width='0' height='0' style='display:none'/>

    </noscript>

    <script>
    (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', 'UA-61539943-2', 'clarktoys.com');
    ga('send', 'pageview');
    ga('require', 'ecommerce', 'ecommerce.js');

    function trackEcommerce() {
    this._addTrans = addTrans;
    this._addItem = addItems;
    this._trackTrans = trackTrans;
    }
    function addTrans(orderID,store,total,tax,shipping,city,state,country) {
    ga('ecommerce:addTransaction', {
    'id': orderID,
    'affiliation': store,
    'revenue': total,
    'tax': tax,
    'shipping': shipping,
    'city': city,
    'state': state,
    'country': country
    });
    }
    function addItems(orderID,sku,product,variation,price,qty) {
    ga('ecommerce:addItem', {
    'id': orderID,
    'sku': sku,
    'name': product,
    'category': variation,
    'price': price,
    'quantity': qty
    });
    }
    function trackTrans() {
    ga('ecommerce:send');
    }
    var pageTracker = new trackEcommerce();
    </script>
    <script src="https://conduit.mailchimpapp.com/js/