Quantcast
Channel: Piwik Forums - Support & Bugs
Viewing all articles
Browse latest Browse all 13117

Re: Setting gt_ms measure for IE8 users

$
0
0
I finally found a solution.

First, on my template page, I add this:

<html>
    <head>
        <!--[if lte IE 8]>
            <script src="/public/javascripts/piwik-extension.js'" type="text/javascript" charset="UTF-8"></script>
        <![endif]-->

This script only contains a declaration of a variable with the timestamp:

var PIWIK_startingTime = new Date().getTime();

In the code snippet for Piwik tracker, I put that:


<script type="text/javascript">
    var _paq = _paq || [];

    // Detection of Browser name and version
    var whoIam = navigator.sayswho= (function(){
        var ua= navigator.userAgent,
                N= navigator.appName, tem,
                M= ua.match(/(opera|chrome|safari|firefox|msie|trident)\/?\s*([\d\.]+)/i) || [];
        M= M[2]? [M[1], M[2]]:[N, navigator.appVersion, '-?'];
        if(M && (tem= ua.match(/version\/([\.\d]+)/i))!= null) M[2]= tem[1];
        return M.join(' ');
    })();

    // Check if the browser is IE6, IE7 or IE8...
    if (/MSIE [6,7,8]/.test(whoIam)) {
        // In that case, calculate manually the gt_ms (Average Generation Time)
        var avg_gt_ms = new Date().getTime() - PIWIK_startingTime;
        _paq.push(["setGenerationTimeMs", avg_gt_ms]);
    }

    _paq.push(["trackPageView"]);
    _paq.push(["enableLinkTracking"]);
    ...

It works on IE8 now.

If you have a better solution, please share it, I would be happy to see it.

Viewing all articles
Browse latest Browse all 13117

Trending Articles