Difference between revisions of "MediaWiki:Common.js"

From SchemeServe Help
Jump to: navigation, search
Line 19: Line 19:
 
             trackcmp_s[0].parentNode.appendChild(trackcmp);
 
             trackcmp_s[0].parentNode.appendChild(trackcmp);
 
             console.log("trying s.length");
 
             console.log("trying s.length");
 +
            console.log(trackcmp);
  
 
         } else {
 
         } else {

Revision as of 21:43, 24 August 2018

    // Set to false if opt-in required
    var trackByDefault = true;

    function acEnableTracking() {
        var expiration = new Date(new Date().getTime() + 1000*60*60*24*30);
        document.cookie = "ac_enable_tracking=1; expires= " + expiration + "; path=/";
        acTrackVisit();
    }

    function acTrackVisit() {
        console.log("Trying to Track visit");
        var trackcmp_email = '';
        var trackcmp = document.createElement("script");
        trackcmp.async = true;
        trackcmp.type = 'text/javascript';
        trackcmp.src = '//trackcmp.net/visit?actid=1000065698&e=' + encodeURIComponent(trackcmp_email) + '&r=' + encodeURIComponent(document.referrer) + '&u=' + encodeURIComponent(window.location.href);
        var trackcmp_s = document.getElementsByTagName("script");
        if (trackcmp_s.length) {
            trackcmp_s[0].parentNode.appendChild(trackcmp);
            console.log("trying s.length");
            console.log(trackcmp);

        } else {
            var trackcmp_h = document.getElementsByTagName("head");
            trackcmp_h.length && trackcmp_h[0].appendChild(trackcmp);
            console.log("trying ELSE");
        }
    }

    console.log("acEnableTracking loaded");


    if (trackByDefault || /(^|; )ac_enable_tracking=([^;]+)/.test(document.cookie)) {
        acEnableTracking();
        console.log("acTrackingEnabled");
    }
	
  console.log("acEnableTracking end");