Changeset 118059 in spip-zone for _plugins_/google_analytics


Ignore:
Timestamp:
Oct 8, 2019, 3:41:20 AM (6 weeks ago)
Author:
Samuel
Message:

Ajout du choix de la méthode de transport (image, xhr ou beacon)

Location:
_plugins_/google_analytics/branches/transport_method
Files:
6 edited
1 copied

Legend:

Unmodified
Added
Removed
  • _plugins_/google_analytics/branches/transport_method/formulaires/configurer_googleanalytics.html

    r92764 r118059  
    2323                            </div>
    2424                        </li>
     25                        <li class="editer editer_ga_transport">
     26                                <label for="ga_transport"><:googleanalytics:label_ga_transport:></label>
     27                                <select name="ga_transport" id="ga_transport">
     28                                        <option value="" [(#ENV{ga_transport}|=={""}|?{'selected="selected"',''})]><:googleanalytics:transport_par_defaut:></option>
     29                                        <option value="image" [(#ENV{ga_transport}|=={image}|?{'selected="selected"',''})]><:googleanalytics:transport_image:></option>
     30                                        <option value="xhr" [(#ENV{ga_transport}|=={xhr}|?{'selected="selected"',''})]><:googleanalytics:transport_xhr:></option>
     31                                        <option value="beacon" [(#ENV{ga_transport}|=={beacon}|?{'selected="selected"',''})]><:googleanalytics:transport_beacon:></option>
     32                                </select>
     33                        </li>
     34
    2535                </ul>
    2636                <p class="boutons">
  • _plugins_/google_analytics/branches/transport_method/googleanalytics_insert_head.php

    r109689 r118059  
    3535        $id_google = lire_config('googleanalytics/idGoogle');
    3636        $cookiebar = (isset($_COOKIE["cb-enabled"]) ? $_COOKIE["cb-enabled"] : '');
    37         $displayCookieConsent = ((isset($_COOKIE["displayCookieConsent"]) and strlen($_COOKIE["displayCookieConsent"])) ? $_COOKIE["displayCookieConsent"] : 'y');
     37        $displayCookieConsent = (isset($_COOKIE["displayCookieConsent"]) ? $_COOKIE["displayCookieConsent"] : 'y');
     38
     39        $transport = "";
     40        if (!empty(lire_config('googleanalytics/ga_transport'))) {
     41                $transport = "ga('set', 'transport', '".lire_config('googleanalytics/ga_transport')."');";
     42                if (lire_config('googleanalytics/ga_transport') == "beacon") {
     43                        $transport = "if (navigator.sendBeacon) {".$transport."}";
     44                }
     45        }
     46
    3847        if ($id_google
    3948          AND $id_google !== '_'
     
    4655  (window,document,'script','//www.google-analytics.com/analytics.js','ga');
    4756  ga('create', '".$id_google."');
     57    ".$transport."
    4858    ga('send', 'pageview');
    4959/*]]>*/</script>\n";
  • _plugins_/google_analytics/branches/transport_method/lang/googleanalytics_en.php

    r88206 r118059  
    1515        'label_id_google' => 'Your Google Analytics ID like "UA-12345"',
    1616        'label_ga_universal' => 'Use <a href="https://support.google.com/analytics/answer/2790010?hl%3Den">Google Analytics Universal</a>',
     17        'label_ga_transport' => 'Transport method (Only with Universal)',
     18
     19        // T
     20        'transport_par_defaut' => 'Default',
     21        'transport_image' => 'image',
     22        'transport_xhr' => 'xhr',
     23        'transport_beacon' => 'beacon (if supported by browser)',
    1724);
    1825?>
  • _plugins_/google_analytics/branches/transport_method/lang/googleanalytics_fr.php

    r88206 r118059  
    1515        'label_id_google' => 'Votre identifiant Google Analytics du type "UA-1234567-1"',
    1616        'label_ga_universal' => 'Utiliser <a href="https://support.google.com/analytics/answer/2790010?hl%3Den">Google Analytics Universal</a>',
     17        'label_ga_transport' => 'Méthode de transport (uniquement avec Universal)',
     18
     19        // T
     20        'transport_par_defaut' => 'Par défaut',
     21        'transport_image' => 'image',
     22        'transport_xhr' => 'xhr',
     23        'transport_beacon' => 'beacon (si le navigateur le supporte)',
     24
    1725);
    1826?>
  • _plugins_/google_analytics/branches/transport_method/paquet.xml

    r109689 r118059  
    22        prefix="googleanalytics"
    33        categorie="statistique"
    4         version="0.5.4"
     4        version="0.5.6"
    55        etat="stable"
    66        compatibilite="[1.9.2;3.2.*]"
  • _plugins_/google_analytics/branches/transport_method/plugin.xml

    r109690 r118059  
    33        <slogan>Utiliser le service Google Analytics</slogan>
    44        <auteur>Phil</auteur>
    5         <version>0.5.4</version>
     5        <version>0.5.6</version>
    66        <etat>stable</etat>
    77        <licence>GNU/GPL</licence>
Note: See TracChangeset for help on using the changeset viewer.