5 Replies Latest reply: Jan 10, 2012 12:43 PM by hlynnt RSS

Google analytics script is causing browser to crash when user clicks on chat

New Member
Currently Being Moderated

My browser is crashing or giving me an error message when I click on the the chat button. The error messages are either google analytics code or the live person script

bug2.PNG

script stopped our chats from working.PNG

 

Has anyone had this happen before?

 

therecoveryplace.net

  • 1. Re: Google analytics script is causing browser to crash when user clicks on chat
    Adrian E. LivePerson Employee
    Currently Being Moderated

    Looking through your code I noticed that there is a duplication of some of the Google Analytics variables. I've attached the code in question and higlighted the duplicates:

     

    <script type="text/javascript">
        var _gaq = _gaq || [];
        _gaq.push(['_setAccount', 'UA-9754593-1']);
        _gaq.push(['_trackPageview']);
        (function () {
            var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
            ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
            var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
        })();
    </script>
    <!-- LIVEPERSON GOOGLE TRACKING CODE -->
    <script type="text/javascript">
        var _gaq = _gaq || [];
        _gaq.push(['_setAccount', 'UA-XXXXXXXX-X']);
        _gaq.push(['_setDomainName', 'none']);
        _gaq.push(['_setAllowLinker', true]);
        _gaq.push(['_setAllowHash', false]);
       _gaq.push(['_trackPageview']);
        (function () {
            var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
            ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
            var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
        })();
    </script>

     

    The second portion of code also contains the function _setAccount but the Google profile ID is still XXXXXX-X which might be the cause of the script getting stuck: Google may not know how to resolve a non-existent (or non-numeric) profile.

     

    Below is another snippet of the code as it should appear for your account. Try replacing the above with the code below and see let me know if it resolves your issue

     

     

    <!-- LIVEPERSON GOOGLE TRACKING CODE -->
    <script type="text/javascript">
        var _gaq = _gaq || [];
        _gaq.push(['_setAccount', 'UA-9754593-1']);
        _gaq.push(['_setDomainName', 'none']);
        _gaq.push(['_setAllowLinker', true]);
        _gaq.push(['_setAllowHash', false]);
        _gaq.push(['_trackPageview']);
        (function () {
            var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
            ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
            var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
        })();
    </script>
  • 2. Re: Google analytics script is causing browser to crash when user clicks on chat
    New Member
    Currently Being Moderated

    I've removed the duplicate Google Tracking and am still getting the following error message when I click on the live person button.

     

    livepersonBUG.PNG

  • 3. Re: Google analytics script is causing browser to crash when user clicks on chat
    Adrian E. LivePerson Employee
    Currently Being Moderated

    I've also taken another look into your code and noticed you have altered the monitor tag. Below is your code:

     

    <script type="text/javascript">
        function initLivePersonVars() {
            if (typeof (lpMTagConfig) == "undefined") { lpMTagConfig = {}; }
            if (typeof (lpMTagConfig.sessionVar) == "undefined") { lpMTagConfig.sessionVar = []; }
            var number6;
            if (number6 = __NAS.get('ictnumbers_6')) {
                lpMTagConfig.sessionVar[lpMTagConfig.sessionVar.length] = 'Call In Number=' + number6;
                lpMTagConfig.sessionVar[lpMTagConfig.sessionVar.length] = 'Infinity ID=' + __NAS.get('ictvid');
            };
            if (typeof (lpMTagConfig.pageVar) == "undefined") { lpMTagConfig.pageVar = []; }
            lpMTagConfig.pageVar[lpMTagConfig.pageVar.length] = 'Website=' + document.domain;
            lpAddMonitorTag();
        };
        var lpMTagConfig = { 'lpServer': "server.iad.liveperson.net", 'lpNumber': "51413982", 'lpProtocol': (document.location.toString().indexOf('https:') == 0) ? 'https' : 'http' }; function lpAddMonitorTag(src) { if (typeof (src) == 'undefined' || typeof (src) == 'object') { src = lpMTagConfig.lpMTagSrc ? lpMTagConfig.lpMTagSrc : '/hcp/html/mTag.js'; } if (src.indexOf('http') != 0) { src = lpMTagConfig.lpProtocol + "://" + lpMTagConfig.lpServer + src + '?site=' + lpMTagConfig.lpNumber; } else { if (src.indexOf('site=') < 0) { if (src.indexOf('?') < 0) src = src + '?'; else src = src + '&'; src = src + 'site=' + lpMTagConfig.lpNumber; } }; var s = document.createElement('script'); s.setAttribute('type', 'text/javascript'); s.setAttribute('charset', 'iso-8859-1'); s.setAttribute('src', src); document.getElementsByTagName('head').item(0).appendChild(s); };
        </script>

    In red is code that is not part of the standard code generated from the LivePerson Admin Console. I understand from the nature of the code that you are trying to pass custom variables through the system. Please take a moment to review how to add custom variables through the LivePerson interface and avoid making manual code adjustments. These are not supported and can affect functionality.

     

    I replaced your monitor tag code with a standard version (attached below) and the chat started to work as expected. Let me know if you need help with setting up your custom variables on your site.

     

    <!-- BEGIN LivePerson Monitor. -->

    <script language='javascript'>   

    var lpMTagConfig = { 'lpServer': "server.iad.liveperson.net", 'lpNumber': "51413982", 'lpProtocol': (document.location.toString().indexOf('https:') == 0) ? 'https' : 'http' }; function lpAddMonitorTag(src) { if (typeof (src) == 'undefined' || typeof (src) == 'object') { src = lpMTagConfig.lpMTagSrc ? lpMTagConfig.lpMTagSrc : '/hcp/html/mTag.js'; } if (src.indexOf('http') != 0) { src = lpMTagConfig.lpProtocol + "://" + lpMTagConfig.lpServer + src + '?site=' + lpMTagConfig.lpNumber; } else { if (src.indexOf('site=') < 0) { if (src.indexOf('?') < 0) src = src + '?'; else src = src + '&'; src = src + 'site=' + lpMTagConfig.lpNumber; } }; var s = document.createElement('script'); s.setAttribute('type', 'text/javascript'); s.setAttribute('charset', 'iso-8859-1'); s.setAttribute('src', src); document.getElementsByTagName('head').item(0).appendChild(s); } if (window.attachEvent) window.attachEvent('onload', lpAddMonitorTag); else window.addEventListener("load", lpAddMonitorTag, false);</script>

    <!-- END LivePerson Monitor. -->

  • 4. Re: Google analytics script is causing browser to crash when user clicks on chat
    New Member
    Currently Being Moderated

    Thank You!

     

    That worked.

     

    Our last developer wrote that chunk of code. I'll have to look into it and see what it was doing. But our chat system is up and running again. Thank you so much.

  • 5. Re: Google analytics script is causing browser to crash when user clicks on chat
    Adrian E. LivePerson Employee
    Currently Being Moderated

    Great news! Happy chatting!

     

More Like This

  • Retrieving data ...

Legend

  • Correct Answers - 5 points
  • Helpful Answers - 4 points