Codes sources
Transcription
Codes sources
Partie I Google Analytics élémentaire Chapitre 1 Installation de Google Analytics 1.1 Ouverture d'un compte Google Analytics 1.1.1 Ouvrir un compte Google 1.1.2 Ouvrir un compte Google Analytics par Google AdWords 1.1.3 Ouvrir un compte Google Analytics sans Google AdWords 1.1.4 Réglages de base de votre compte Google Analytics 1.2 Installation du code de suivi Google Analytics 1.2.1 Description du code de suivi <script type="text/JavaScript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-XXXXXX-X']); _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> © 2012 Pearson France – Google Analytics, 2e édition – Alan Boydell, Serge Descombes, Sébastien Manaches 1.2.2 Où installer le code ? <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="fr-FR"> <head profile="http://gmpg.org/xfn/11"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <script type="text/JavaScript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-XXXXXX-X']); _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> </head> <body> ... </body> </html> 1.2.3 Pourquoi installer le code dès maintenant ? Chapitre 2 © 2012 Pearson France – Google Analytics, 2e édition – Alan Boydell, Serge Descombes, Sébastien Manaches Les principes essentiels de Google Analytics 2.1 Le site Internet concerné 2.1.1 Pourquoi avoir créé un site Internet ? 2.1.2 Domaines et sous-domaines 2.1.3 Technologies présentes sur le site 2.1.4 Récupérer des données e-commerce ou de formulaire 2.2 Google Analytics, les premiers pas 2.2.1 Le compte Google Analytics 2.2.2 Les paramètres d'un compte Google Analytics 2.2.3 Le site Google Analytics 2.2.4 Le profil Google Analytics 2.2.5 Les paramètres d'un profil 2.2.6 Les objectifs de conversion 2.2.7 Créer un profil avant d'appliquer un filtre 2.2.8 Les filtres 2.2.9 Les utilisateurs 2.3 Méthode de collecte des données 2.3.1 Le code de suivi <script type="text/JavaScript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-27961869-1']); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/JavaScript'; ga.async = true; © 2012 Pearson France – Google Analytics, 2e édition – Alan Boydell, Serge Descombes, Sébastien Manaches 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.3.2 Les cookies de Google Analytics 2.3.3 La méthode de collecte des données Chapitre 3 © 2012 Pearson France – Google Analytics, 2e édition – Alan Boydell, Serge Descombes, Sébastien Manaches Utilisation de Google Analytics 3.1 Vérification de la présence des données dans l'interface 3.1.1 La liste des profils 3.1.2 Les données ne remontent pas : dépannage Vérifier la présence du code de suivi Vérifier l'intégrité du code de suivi Vérifier l'état d'implémentation du profil 3.2 Organisation de l'interface 3.2.1 Partie supérieure : la tête et la barre horizontale orange 3.2.2 Partie gauche : les sections, l'aide 3.3 La partie centrale de l'interface : le rapport 3.3.1 Le calendrier 3.3.2 La courbe et les onglets 3.3.3 Le tableau 3.3.4 Les fonctions d'export 3.4 Organisation des rapports : les sections et soussections 3.4.1 Audience 3.4.2 Publicité 3.4.3 Sources de trafic 3.4.4 Contenu © 2012 Pearson France – Google Analytics, 2e édition – Alan Boydell, Serge Descombes, Sébastien Manaches 3.4.5 Conversions 3.5 Une autre visualisation des données : l’API 3.6 Conclusion © 2012 Pearson France – Google Analytics, 2e édition – Alan Boydell, Serge Descombes, Sébastien Manaches Partie II Google Analytics avancé © 2012 Pearson France – Google Analytics, 2e édition – Alan Boydell, Serge Descombes, Sébastien Manaches Chapitre 4 Utilisation avancée de Google Analytics 4.1 Les indicateurs clés de performance 4.1.1 De la donnée à l'action 4.1.2 Des KPI et des hommes 4.2 Mesure correcte d'une visite 4.2.1 Des visiteurs, des visites et des pages vues <script type="text/JavaScript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-XXXXXX-X']); _gaq.push(['_setSessionCookieTimeout', 600000]); _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> 4.2.2 Gestion des sous-domaines _gaq.push(['_setDomainName', '.MonSite.fr']); <script type="text/JavaScript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-XXXXXX-X']); _gaq.push(['_setDomainName', '.MonSite.fr']); _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); © 2012 Pearson France – Google Analytics, 2e édition – Alan Boydell, Serge Descombes, Sébastien Manaches })(); </script> 4.2.3 Profils agrégés et profils séparés par domaines/sousdomaines 4.2.4 Gestion des domaines tiers (avec ou sans sous-domaine associé) <script type="text/JavaScript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-XXXXXX-X']); _gaq.push(['_setAllowLinker', true]); _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> <a href=www.MonDeuxiemeSite.fr/page1.html onclick= "_gaq.push(['_link', this.href]); return false;"> <form action="http://www.MonDeuxiemeSite.fr/form.cgi" onSubmit="_gaq.push(['_linkByPost', this]);"> 4.2.5 Profils par domaines tiers 4.2.6 Suivi multicompte <script type="text/JavaScript"> var _gaq = _gaq || []; _gaq.push(['firstTracker._setAccount', 'UA-XXXXXX-X']); _gaq.push(['firstTracker._trackPageview']); _gaq.push(['secondTracker._setAccount', 'UA-YYYYYY-Y']); _gaq.push(['secondTracker._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> © 2012 Pearson France – Google Analytics, 2e édition – Alan Boydell, Serge Descombes, Sébastien Manaches 4.2.7 Gestion des frames (cadres) 4.2.8 Gestion des iFrames <script type=text/JavaScript> var generateLinkerUrl = function(url){ var returnValue = "-"; if(url){ var parseCookieString=function(stringToParse,startStringRegex,endStringRegex) { var returnUGC="-"; if(stringToParse&&startStringRegex&&endStringRegex){ var regUgc = new RegExp("(?:"+startStringRegex+")(.+?)(?:"+endStringRegex+"|$)"); var resUgc = regUgc.exec(stringToParse); if(resUgc&&resUgc.length>1){ returnUGC = resUgc[1]; } } return returnUGC; }; var hashThis=function(d){ if (!d || d=="") return 1; var h=0,g=0; for (var i=d.length-1;i>=0;i--) { var c=parseInt(d.charCodeAt(i),10); h=((h << 6) & 0xfffffff) + c + (c << 14); if ((g=h & 0xfe00000)!=0) h=(h ^ (g >> 21)); } return h; }; var dc = document.cookie; if(dc){ var a = parseCookieString(dc, "__utma=", ";"); var b = parseCookieString(dc, "__utmb=", ";"); var c = parseCookieString(dc, "__utmc=", ";"); var x = parseCookieString(dc, "__utmx=", ";"); var z = parseCookieString(dc, "__utmz=", ";"); var v = parseCookieString(dc, "__utmv=", ";"); var valueString = []; valueString.push(a); valueString.push(b); valueString.push(c); valueString.push(x); © 2012 Pearson France – Google Analytics, 2e édition – Alan Boydell, Serge Descombes, Sébastien Manaches valueString.push(z); valueString.push(v); valueString = valueString.join(""); var k = hashThis(valueString); var params = []; params.push("__utma="); params.push(a); params.push("&__utmb="); params.push(b); params.push("&__utmc="); params.push(c); params.push("&__utmx="); params.push(x); params.push("&__utmz="); params.push(z); params.push("&__utmv="); params.push(v); params.push("&__utmk="); params.push(k); params = params.join(""); } returnValue = url + (url.match(/\?/i)?'&':'?') + params; } return returnValue; } </script> var newUrl = generateLinkerUrl("http://AutreDomaine.com/mapagefille.html"); http:// AutreDomaine.com/mapagefille.html?__utma=1234567.1567196865.1324050830.13 24050830.1324050830.1&__utmb=1234567.1.10.1324050830&__utmc=1234567&__utm x=&__utmz=1234567.1324050830.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(no ne)&__utmv=-&__utmk=26482997 <script type="text/JavaScript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-XXXXXX-X']); _gaq.push(['_setAllowLinker', true]); _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); })(); © 2012 Pearson France – Google Analytics, 2e édition – Alan Boydell, Serge Descombes, Sébastien Manaches </script> 4.2.9 Filtres personnalisés 4.2.10 Hébergement local du ga.js <script type="text/JavaScript"> (function() { var ga = document.createElement('script'); ga.type = 'text/JavaScript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.MonSite.com/MonFichierAnalytics.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); </script> 4.3 Mesure correcte d'une interaction 4.3.1 Suivi du commerce électronique (e-commerce) sur une page de confirmation d'achat <script type="text/JavaScript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-XXXXXX-X']); _gaq.push(['_trackPageview']); _gaq.push(['_addTrans', "@ID_TRANS", // Numéro unique de transaction "@ID_AFFILIE", // Affiliation "@TOTAL_HT", // Total HT de la transaction "@TAXE", // Taxe "@LIVRAISON", // Prix de la livraison "@VILLE", // Ville "@REGION", // Région "@PAYS" // Pays ]); _gaq.push(['_addItem', "@ID_TRANS", // Numéro unique de transaction "@CODE_PRODUIT", // Code produit "@NOM_PRODUIT", // Nom du produit "@CAT_PRODUIT", // Catégorie "@PRIX_PRODUIT", // Prix "@QUANTITE_PRODUIT" // Quantité ]); _gaq.push(['_trackTrans']); (function() { © 2012 Pearson France – Google Analytics, 2e édition – Alan Boydell, Serge Descombes, Sébastien Manaches 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 <script type="text/JavaScript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-XXXXXX-X']); _gaq.push(['_trackPageview']); _gaq.push(['_addTrans', "1234", // Numéro unique de transaction "Mon affilié n°1", // Affiliation "14.00", // Total HT de la transaction "2.74", // Taxe "5", // Prix de la livraison "Sigean", // Ville "Languedoc", // Région "France" // Pays ]); _gaq.push(['_addItem', "1234", // Numéro unique de transaction "AOC", // Code produit "Grand Opéra", // Nom du produit "Rouge", // Catégorie "7.50", // Prix "2" // Quantité ]); _gaq.push(['_trackTrans']); (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> <script type="text/JavaScript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-XXXXXX-X']); _gaq.push(['_trackPageview']); _gaq.push(['_addTrans', © 2012 Pearson France – Google Analytics, 2e édition – Alan Boydell, Serge Descombes, Sébastien Manaches "1234", // Numéro unique de transaction "Mon affilié n°1", // Affiliation "14.00", // Total HT de la transaction "2.74", // Taxe "5", // Prix de la livraison "Sigean", // Ville "Languedoc", // Région "France" // Pays ]); _gaq.push(['_addItem', "1234", // Numéro unique de transaction "AOC-GO-2007-9876", // Code produit "Grand Opéra ", // Nom du produit "AOC Rouge 2007", // Catégorie "7,50 ", // Prix "6" // Quantité ]); _gaq.push(['_addItem', "1234", // Numéro unique de transaction "L-2008-5674", // Code produit "Leucate", // Nom du produit "Blanc Blanc 2008", // Catégorie "5.00", // Prix "6" // Quantité ]); _gaq.push(['_addItem', "1234", // Numéro unique de transaction "Cadeau 77866", // Code produit "Tire bouchon", // Nom du produit "Cadeau", // Catégorie "0,00", // Prix "1" // Quantité ]); _gaq.push(['_trackTrans']); (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> <script type="text/JavaScript"> © 2012 Pearson France – Google Analytics, 2e édition – Alan Boydell, Serge Descombes, Sébastien Manaches var orderId = document.location.hostname + '_1234' var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-XXXXXX-X']); _gaq.push(['_trackPageview']); _gaq.push(['_addTrans', orderId, // Numéro unique de transaction "Mon affilié n°1", // Affiliation "14.00", // Total HT de la transaction "2.74", // Taxe "5", // Prix de la livraison "Sigean", // Ville "Languedoc", // Région "France" // Pays ]); _gaq.push(['_addItem', orderId, // Numéro unique de transaction "AOC-GO–2007–9876", // Code produit "Grand Opéra ", // Nom du produit "AOC Rouge 2007", // Catégorie "7,50 ", // Prix "6" // Quantité ]); _gaq.push(['_trackTrans']); (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> 4.3.2 Suivi du commerce électronique avec un domaine tiers de paiement Codes de suivi Google Analytics sur les pages tierces <script type="text/JavaScript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-XXXXXX-X']); _gaq.push(['_setDomainName', 'none']); _gaq.push(['_setAllowLinker', true]); _gaq.push(['_trackPageview']); (function() { © 2012 Pearson France – Google Analytics, 2e édition – Alan Boydell, Serge Descombes, Sébastien Manaches 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> <a href=www.MonDeuxiemeSite.fr/page1.html onclick= "_gaq.push(['_link', this.href]); return false;"> <form action="http://www.MonDeuxiemeSite.fr/form.cgi" onSubmit="_gaq.push(['_linkByPost', this]);"> <script type="text/JavaScript"> var orderId = document.location.hostname + '_1234' var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-XXXXXX-X']); _gaq.push(['_setDomainName', 'none']); _gaq.push(['_setAllowLinker', true]); _gaq.push(['_trackPageview']); _gaq.push(['_addTrans', orderId, "Mon affilié n°1", // Numéro unique de transaction // Affiliation "14.00", // Total HT de la transaction "2.74", // Taxe "5", // Prix de la livraison "Sigean", // Ville "Languedoc", // Région "France" // Pays ]); _gaq.push(['_addItem', orderId, // Numéro unique de transaction "AOC-GO-2007-9876", // Code produit "Grand Opéra ", // Nom du produit "AOC Rouge 2007", // Catégorie "7,50 ", // Prix "6" // Quantité ]); _gaq.push(['_trackTrans']); (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); })(); © 2012 Pearson France – Google Analytics, 2e édition – Alan Boydell, Serge Descombes, Sébastien Manaches </script> Pas de code Google Analytics sur les pages tierces <script type="text/JavaScript"> var orderId = document.location.hostname + '_1234' var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-XXXXXX-X']); _gaq.push(['_trackPageview']); _gaq.push(['_addTrans', orderId, "Mon affilié n°1", // Numéro unique de transaction // Affiliation "14.00", // Total HT de la transaction "2.74", // Taxe "5", // Prix de la livraison "Sigean", // Ville "Languedoc", // Région "France" // Pays ]); _gaq.push(['_addItem', orderId, // Numéro unique de transaction "AOC-GO-2007-9876", // Code produit "Grand Opéra ", // Nom du produit "AOC Rouge 2007", // Catégorie "7,50 ", // Prix "6" // Quantité ]); (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> <a href=www.Banque.fr/CB.html onclick= "_gaq.push(['_trackTrans']);"> <form action="http:// www.Banque.fr/form.cgi" onSubmit="_gaq.push(['_trackTrans']);"> 4.3.3 Le suivi d'événement _gaq.push(['_trackEvent', Categorie, Action, Label, Valeur, Noninteraction]); _gaq.push(['_trackEvent', 'Vidéo', 'Lecture', 'Démo du nouveau produit', 10]); _gaq.push(['_trackEvent', 'Vidéo', 'Pause', 'Démo du nouveau produit']); _gaq.push(['_trackEvent', 'Vidéo', 'Stop', 'Démo du nouveau produit']); © 2012 Pearson France – Google Analytics, 2e édition – Alan Boydell, Serge Descombes, Sébastien Manaches _gaq.push(['_trackEvent', 'Vidéo', 'Téléchargement', 'Démo du nouveau produit']); _gaq.push(['_trackEvent', 'Vidéo', 'Partage', 'Démo du nouveau produit']); _gaq.push(['_trackEvent', 'Vidéo - Démo', 'Actions Lecture-Pause-Stop', 'Démo du nouveau produit', 10]); _gaq.push(['_trackEvent', 'Vidéo - Démo', 'Actions Lecture-Pause-Stop', 'Le Boss', 10]); _gaq.push(['_trackEvent', 'Vidéo - Téléchargement', 'Mpeg', 'Démo du produit']); _gaq.push(['_trackEvent', 'Vidéo - Téléchargement', 'Avi', 'Démo du produit']); _gaq.push(['_trackEvent', 'Vidéo - Téléchargement', 'WMV', 'Démo du produit']); _gaq.push(['_trackEvent', 'Vidéo', 'Temps de chargement', 'Démo du produit', downloadTime]); _gaq.push(['_trackEvent', 'Vidéo', 'Lecture', '', 10]); 4.3.4 La comptabilisation des événements 4.3.5 Suivi des interactions sociales _gaq.push(['_trackSocial', reseau, action, cible, page]); 4.3.6 Réglage du suivi du temps de chargement des pages <script type="text/JavaScript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-XXXXXX-X']); _gaq.push(['_setSiteSpeedSampleRate', 5]); _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> 4.3.7 Les autres interactions Générer une URL virtuelle <script type="text/JavaScript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-XXXXXX-X']); _gaq.push(['_trackPageview', 'Enregistrement/Etape1']); © 2012 Pearson France – Google Analytics, 2e édition – Alan Boydell, Serge Descombes, Sébastien Manaches (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> Suivre des actions Flash et Flex playGame.addEventListener(MouseEvent.CLICK, onButtonClick ); function onButtonClick( event:Event ):void { _gaq.push(['_trackPageview', 'MyGame']); } Suivre la page d'erreur "page inconnue" ou "page 404" _gaq.push(['_trackPageview', '/Page404']); 4.3.8 Entonnoirs de conversion 4.3.9 La comptabilisation des étapes et des objectifs Chapitre 5 Personnalisation de la collecte des données 5.1 Les valeurs personnalisées 5.1.1 Définition et utilisation des valeurs personnalisées 5.1.2 Mise en place des valeurs personnalisées _gaq.push(['_setVar', 'valeur']); _gaq.push(['_setVar', 'registered']); <script type="text/JavaScript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-XXXXXX-X']); _gaq.push(['_trackPageview']); _gaq.push(['_setVar', 'acheteurs']); (function() { var ga = document.createElement('script'); ga.type = 'text/JavaScript'; ga.async = true; © 2012 Pearson France – Google Analytics, 2e édition – Alan Boydell, Serge Descombes, Sébastien Manaches 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> <a href="lien.html" onClick="_gaq.push(['_setVar', 'registered']);">Identifiez-vous</a> Homme : <INPUT type=radio name="sexe" value="M" onClick="_gaq.push(['_setVar', 'Masculin']);"> <br>Femme : <INPUT type=radio name="sexe" value="F" onClick="_gaq.push(['_setVar', 'Feminin']);"> 5.2 Les variables personnalisées 5.2.1 Définition et utilisation des variables personnalisées 5.2.2 Mise en place des variables personnalisées _gaq.push(['_setCustomVar', 'index', 'name', 'value', 'opt_scope']); <script type="text/JavaScript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-XXXXXX-X']); _gaq.push(['_setCustomVar', 1, 'Marque', 'LG', 3]); _gaq.push(['_setCustomVar', 2, 'TypePage', 'Presentation', 3]); _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> <script type="text/JavaScript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-XXXXXX-X']); _gaq.push(['_setCustomVar', 1, 'Marque', Nokia, 3]); _gaq.push(['_setCustomVar', 2, 'TypePage', 'Presentation', 3]); _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); © 2012 Pearson France – Google Analytics, 2e édition – Alan Boydell, Serge Descombes, Sébastien Manaches })(); </script> <script type="text/JavaScript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-XXXXXX-X']); _gaq.push(['_setCustomVar', 1, 'Marque', 'LG', 3]); _gaq.push(['_setCustomVar', 2, 'TypePage', Produit, 3]); _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> <a href="lien.html" onClick="_gaq.push(['_setCustomVar', 1, 'Visiteurs', 'Identifies', 2]);">Identifiez-vous</a> Homme : <INPUT type=radio name="sexe" value="M" onClick="_gaq.push(['_setCustomVar', 4, 'Sexe', 'Masculin', 1]);"> <br>Femme : <INPUT type=radio name="sexe" value="F" onClick="_gaq.push(['_setCustomVar', 4, 'Sexe', 'Feminin', 1]);"> Chapitre 6 © 2012 Pearson France – Google Analytics, 2e édition – Alan Boydell, Serge Descombes, Sébastien Manaches Les sources de trafic 6.1 L'origine d'une visite — les cinq différents ingrédients 6.1.1 La source et le support de la campagne 6.1.2 Le terme de la campagne/mot clé 6.1.3 Le nom de la campagne 6.1.4 Le contenu de la campagne 6.2 Les origines naturelles 6.2.1 Accès directs 6.2.2 Sites référents 6.2.3 Moteurs de recherche — les résultats naturels <script type="text/JavaScript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-XXXXXX-X']); _gaq.push(['_addOrganic', 'NomDuMoteur', 'ParamètreRequête']); _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> © 2012 Pearson France – Google Analytics, 2e édition – Alan Boydell, Serge Descombes, Sébastien Manaches 6.2.4 Intégration des outils pour les webmasters (Google Webmasters Tools) 6.3 Google AdWords 6.3.1 Vérification de l’association des données de coûts 6.3.2 Marquage automatique 6.3.3 Rapports propres à Google AdWords 6.4 Les autres sources payantes 6.4.1 Le suivi manuel 6.4.2 Yahoo!, Bing et les autres sources de trafic CPC/CPM 6.4.3 E-mailing 6.5 Autres considérations 6.5.1 Les interactions entre les sources de trafic 6.5.2 L’analyse multicanal de Google Analytics 6.5.3 Utiliser les paramètres de suivi existants < script type="text/JavaScript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-XXXXXX-X']); _gaq.push(['_setCampSourceKey', 'T1']); _gaq.push(['_setCampMediumKey', 'T2']); _gaq.push(['_setCampNameKey', 'T1']); _gaq.push(['_setCampContentKey', 'T3']); _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> © 2012 Pearson France – Google Analytics, 2e édition – Alan Boydell, Serge Descombes, Sébastien Manaches 6.5.4 Récapitulatif de l'attribution de la source de la visite 6.6 Conclusion Chapitre 7 Compréhension et utilisation de Google Analytics 7.1 Définition des données de base 7.1.1 Données de la visite 7.1.2 Données du visiteur 7.1.3 Données de la page vue 7.2 Modification de la visualisation des rapports 7.2.1 Les rapports personnalisés 7.2.2 Les segments avancés 7.2.3 Les alertes Chapitre 8 © 2012 Pearson France – Google Analytics, 2e édition – Alan Boydell, Serge Descombes, Sébastien Manaches Google Analytics Premium 8.1 Des limites étendues 8.2 Des fonctionnalités exclusives 8.3 Des garanties nouvelles et un support 8.4 Comment se procurer Premium 8.5 Conclusion © 2012 Pearson France – Google Analytics, 2e édition – Alan Boydell, Serge Descombes, Sébastien Manaches Partie III Cas pratiques Chapitre 9 © 2012 Pearson France – Google Analytics, 2e édition – Alan Boydell, Serge Descombes, Sébastien Manaches Optimisation des campagnes d'acquisition de trafic 9.1 Obtenir des rapports exclusivement dédiés à vos campagnes Google AdWords 9.1.1 Intérêt 9.1.2 Limites 9.1.3 Méthodologie 9.1.4 Résultat 9.2 Importer uniquement les campagnes Google AdWords pertinentes pour un compte Google Analytics donné 9.2.1 Intérêt 9.2.2 Limites 9.2.3 Méthodologie 9.2.4 Résultat 9.3 Adapter la durée du cookie de campagne à l'activité du site 9.3.1 Intérêt 9.3.2 Limites 9.3.3 Méthodologie <script type="text/JavaScript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-XXXXXX-X']); _gaq.push(['_setCampaignCookieTimeout', 30*24*60*60*1000 ]); _gaq.push(['_trackPageview']); (function() { © 2012 Pearson France – Google Analytics, 2e édition – Alan Boydell, Serge Descombes, Sébastien Manaches 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> 9.3.4 Résultat Chapitre 10 © 2012 Pearson France – Google Analytics, 2e édition – Alan Boydell, Serge Descombes, Sébastien Manaches Contrôle du référencement naturel 10.1 De quelles pages de résultats proviennent les visites ? 10.1.1 Intérêt 10.1.2 Limites 10.1.3 Méthodologie 10.1.4 Résultat 10.2 De quelle position de résultats de Google proviennent les visites ? 10.2.1 Intérêt 10.2.2 Limites 10.2.3 Méthodologie 10.2.4 Résultats 10.3 Ajout d'un moteur de recherche ignoré par Google Analytics 10.3.1 Intérêt 10.3.2 Limites 10.3.3 Méthodologie <script type="text/JavaScript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-XXXXXX-X']); _gaq.push(['_addOrganic', "exalead", "q" ]); _gaq.push(['_addOrganic', "lo.st", "x_query" ]); _gaq.push(['_trackPageview']); (function() { © 2012 Pearson France – Google Analytics, 2e édition – Alan Boydell, Serge Descombes, Sébastien Manaches 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> 10.3.4 Résultat 10.4 Ventilation des versions locales d'un moteur de recherche (Google.fr, Google.com, etc.) 10.4.1 Intérêt 10.4.2 Limites 10.4.3 Méthodologie <script type="text/JavaScript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-XXXXXX-X']); _gaq.push(['_addOrganic', 'google.fr', 'q', true]); _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> <script type="text/JavaScript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-XXXXXX-1']); _gaq.push(['_trackPageview']); _gaq.push(['t2._setAccount', 'UA-XXXXXX-2']); _gaq.push(['t2._addOrganic', 'exalead', 'q' ]); _gaq.push(['t2._addOrganic','google.co.uk','q',true]); _gaq.push(['t2._addOrganic','google.es','q',true]); _gaq.push(['t2._addOrganic','google.pt','q',true]); _gaq.push(['t2._addOrganic','google.it','q',true]); _gaq.push(['t2._addOrganic','google.fr','q',true]); _gaq.push(['t2._addOrganic','google.nl','q',true]); © 2012 Pearson France – Google Analytics, 2e édition – Alan Boydell, Serge Descombes, Sébastien Manaches _gaq.push(['t2._addOrganic','google.be','q',true]); _gaq.push(['t2._addOrganic','google.de','q',true]); _gaq.push(['t2._addOrganic','google.no','q',true]); _gaq.push(['t2._addOrganic','google.se','q',true]); _gaq.push(['t2._addOrganic','google.dk','q',true]); _gaq.push(['t2._addOrganic','google.fi','q',true]); _gaq.push(['t2._addOrganic','google.ch','q',true]); _gaq.push(['t2._addOrganic','google.at','q',true]); _gaq.push(['t2._addOrganic','google.ie','q',true]); _gaq.push(['t2._addOrganic','google.ru','q',true]); _gaq.push(['t2._addOrganic','google.pl','q',true]); _gaq.push(['t2._addOrganic','uk.search.yahoo.com','p',true,'yahoo.uk']); _gaq.push(['t2._addOrganic','es.search.yahoo.com','p',true,'yahoo.es']); _gaq.push(['t2._addOrganic','it.search.yahoo.com','p',true,'yahoo.it']); _gaq.push(['t2._addOrganic','fr.search.yahoo.com','p',true,'yahoo.fr']); _gaq.push(['t2._addOrganic','nl.search.yahoo.com','p',true,'yahoo.nl']); _gaq.push(['t2._addOrganic','de.search.yahoo.com','p',true,'yahoo.de']); _gaq.push(['t2._addOrganic','no.search.yahoo.com','p',true,'yahoo.no']); _gaq.push(['t2._addOrganic','se.search.yahoo.com','p',true,'yahoo.se']); _gaq.push(['t2._addOrganic','dk.search.yahoo.com','p',true,'yahoo.dk']); _gaq.push(['t2._addOrganic','fi.search.yahoo.com','p',true,'yahoo.fi']); _gaq.push(['t2._addOrganic','ch.search.yahoo.com','p',true,'yahoo.ch']); _gaq.push(['t2._addOrganic','at.search.yahoo.com','p',true,'yahoo.at']); _gaq.push(['t2._addOrganic','ru.search.yahoo.com','p',true,'yahoo.ru']); _gaq.push(['t2._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> © 2012 Pearson France – Google Analytics, 2e édition – Alan Boydell, Serge Descombes, Sébastien Manaches 10.4.4 Résultat 10.5 Suivi du trafic provenant de Google Shopping, Google Images et Google Books 10.5.1 Intérêt 10.5.2 Limites 10.5.3 Méthodologie _gaq.push(['_addOrganic', 'google', 'q', true, 'google shopping', '/products/']); <script type="text/JavaScript"> var _gaq = _gaq || []; _gaq.push(['_setAccount','UA-XXXXXX-X']); _gaq.push(['_addOrganic','google','q',true,'google shopping','channel=products']); _gaq.push(['_addOrganic','google','q',true,'google shopping','tbm=shop']); _gaq.push(['_addOrganic','google','q',true,'google shopping','/products/']); _gaq.push(['_addOrganic','google','q',true,'google shopping','source=productsearch']); _gaq.push(['_addOrganic','google','q',true,'google images','/imgres?']); _gaq.push(['_addOrganic','maps.google','q',true,'google maps']); _gaq.push(['_addOrganic','google','q',true,'google maps','/maps']); _gaq.push(['_addOrganic','google','dq',true,'google books','/books']); _gaq.push(['_addOrganic','googleusercontent','q',true,'google user content']); _gaq.push(['_addOrganic','google','as_q',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> © 2012 Pearson France – Google Analytics, 2e édition – Alan Boydell, Serge Descombes, Sébastien Manaches 10.5.4 Résultat 10.6 Protection du référencement naturel contre les effets secondaires du taguage manuel des campagnes 10.6.1 Intérêt <link rel="canonical" href="http://www.monsite.fr/index?php"/> 10.6.2 Limites 10.6.3 Méthodologie <script type="text/JavaScript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-XXXXXX-X']); _gaq.push(['_setAllowAnchor', true]); _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> 10.6.4 Résultat Chapitre 11 © 2012 Pearson France – Google Analytics, 2e édition – Alan Boydell, Serge Descombes, Sébastien Manaches Amélioration du contenu et de l'utilisation du site 11.1 Catégorisation de l'ensemble des pages à l'aide des variables personnalisées 11.1.1 Intérêt 11.1.2 Limites 11.1.3 Méthodologie _gaq.push(['_setCustomVar',1,'categorie_de_la_page', document.location.pathname, 3]); <script type="text/JavaScript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-XXXXX-X']); _gaq.push(['_setCustomVar',1,'Immobilier', document.location.pathname, 3]); _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> <script type="text/JavaScript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-XXXXX-X']); _gaq.push(['_setCustomVar',1,'Immobilier', document.location.pathname, 3]); _gaq.push(['_setCustomVar',2,'Location_appartements', document.location.pathname, 3]); _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); © 2012 Pearson France – Google Analytics, 2e édition – Alan Boydell, Serge Descombes, Sébastien Manaches })(); </script> _gaq.push(['_setCustomVar',1, 'Immobilier','Location_appartements', 3]); 11.1.4 Résultats 11.2 Recherche sur site : paramétrage du module malgré l'absence de paramètres de requête dans l'URL 11.2.1 Intérêt 11.2.2 Limites 11.2.3 Méthodologie <script type="text/JavaScript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-XXXXX-X']); var l = document.location, s = l.search, p = l.pathname; var regSearch = new RegExp("^/search/([^/]+)/"); var resSearch = regSearch.exec(p); if (resSearch) { var s = s + (s.length ? '&' : '?') + "kw=" + resSearch[1]; var pageName = p + s; _gaq.push(['_trackPageview',pageName]); }else{ _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> © 2012 Pearson France – Google Analytics, 2e édition – Alan Boydell, Serge Descombes, Sébastien Manaches 11.2.4 Résultats 11.3 Recherche sur site : analyse des requêtes à zéro résultat 11.3.1 Intérêt 11.3.2 Limites 11.3.3 Méthodologie <div id="main" class="lyt1col"> <img src="http://i4.cdscdn.com/imagesok//search/pa/image_mag/fourmirecherche-1.gif" alt="" width="166" height="256" border="0"> </div> <script type="text/JavaScript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-XXXXX-X']); var l = document.location, s = l.search, p = l.pathname; var regSearch = new RegExp("^/search/([^/]+)/"); var resSearch = regSearch.exec(p); if (resSearch) { var contentResults = document.getElementById('main').innerHTML; if ( contentResults.search('http://i4.cdscdn.com/imagesok//search/pa/image_mag /fourmi-recherche-1.gif') ) { var s = s + (s.length ? '&' : '?') + "cat=sans_resultats" +"&kw=sans_resultats: " + resSearch[1]; var pageName = p + s; _gaq.push(['_trackPageview',pageName]); }else{ var s = s + (s.length ? '&' : '?') + "cat=avec_resultats" +"&kw=" + resSearch[1]; var pageName = p + s; _gaq.push(['_trackPageview',pageName]); } }else{ _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); © 2012 Pearson France – Google Analytics, 2e édition – Alan Boydell, Serge Descombes, Sébastien Manaches })(); </script> 11.3.4 Résultats 11.4 Contrôle des pages d'erreurs consultées par les visiteurs 11.4.1 Intérêt 11.4.2 Limites 11.4.3 Méthodologie ErrorDocument 401 /404.htm ErrorDocument 403 /404.htm ErrorDocument 404 /404.htm <script type="text/JavaScript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-XXXXXX-YY']); var myloc = document.location.pathname; var myref = document.referrer; if (myloc.length == 0) { myloc = "nolocation"; } if (myref.length == 0) { myref = "noreferrer"; } _gaq.push(['_trackPageview', "/404/" + myloc.replace(/\//g, "_") + "/" + myref.replace(/https*:\/\//i, "").replace(/\//g, "_")]); (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> © 2012 Pearson France – Google Analytics, 2e édition – Alan Boydell, Serge Descombes, Sébastien Manaches 11.4.4 Résultat 11.5 Récupération des données saisies dans un formulaire 11.5.1 Intérêt 11.5.2 Limites 11.5.3 Méthodologie <script type="text/JavaScript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-XXXXX-X']); _gaq.push(['_trackPageview']); _gaq.push(['_addTrans', '1234', // Numéro unique de transaction '', // Affiliation '32', // Total HT de la transaction = âge '', // Taxe '', // Prix de la livraison '', // Ville '', // Région '' ]); // Pays _gaq.push(['_addItem', '1234', // Numéro unique de transaction '30-35', // Code de produit = tranche d'âge 'F', // Nom du produit = sexe F ou M 'NewsLetter 1', // Catégorie = NewsLetter 1, 2, toutes, aucune '32', // Prix = âge '1' ]); // Quantité = 1 enregistrement utilisateur _gaq.push(['_trackTrans']); (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> <form action="http://www.Banque.fr/form.cgi" onSubmit="_gaq.push(['_trackTrans']);"> © 2012 Pearson France – Google Analytics, 2e édition – Alan Boydell, Serge Descombes, Sébastien Manaches 11.5.4 Résultat 11.6 Suivi de l'autopromotion par détournement de la recherche sur site 11.6.1 Intérêt 11.6.2 Limites 11.6.3 Méthodologie 11.6.4 Résultats 11.7 Enregistrement de plusieurs conversions par session 11.7.1 Intérêt 11.7.2 Limites 11.7.3 Méthodologie <script type="text/JavaScript"> var orderID = (new Date().getTime()+''+Math.floor(Math.random()*9999999)).toString(); var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-XXXXXX-X']); _gaq.push(['_trackPageview']); _gaq.push(['_addTrans', orderID, "Mon Affilié ABC", "1", "", "", "", "", "" ]); _gaq.push(['_addItem', orderID, "", "Produit AZERTY", "Lien Voir Offre", © 2012 Pearson France – Google Analytics, 2e édition – Alan Boydell, Serge Descombes, Sébastien Manaches "1", "1" ]); _gaq.push(['_trackTrans']); (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> 11.7.4 Résultat 11.8 Analyse avancée d'un entonnoir de conversion e-commerce 11.8.1 Intérêt 11.8.2 Limites 11.8.3 Méthodologie 11.8.4 Résultats Chapitre 12 Applications et sites mobiles 12.1 Mesure d'un site mobile 12.1.1 Intérêt 12.1.2 Limites 12.1.3 Méthodologie Implémentation PHP <?php // Copyright 2010 Google Inc. All Rights Reserved. $GA_ACCOUNT = "MO-XXXXXX-YY"; © 2012 Pearson France – Google Analytics, 2e édition – Alan Boydell, Serge Descombes, Sébastien Manaches $GA_PIXEL = "/ga.php"; function googleAnalyticsGetImageUrl() { global $GA_ACCOUNT, $GA_PIXEL; $url = ""; $url .= $GA_PIXEL . "?"; $url .= "utmac=" . $GA_ACCOUNT; $url .= "&utmn=" . rand(0, 0x7fffffff); $referer = $_SERVER["HTTP_REFERER"]; $query = $_SERVER["QUERY_STRING"]; $path = $_SERVER["REQUEST_URI"]; if (empty($referer)) { $referer = "-"; } $url .= "&utmr=" . urlencode($referer); if (!empty($path)) { $url .= "&utmp=" . urlencode($path); } $url .= "&guid=ON"; return str_replace("&", "&", $url); } ?> <?php $googleAnalyticsImageUrl = googleAnalyticsGetImageUrl(); echo '<img src="' . $googleAnalyticsImageUrl . '" />';?> Implémentation PERL # Copyright 2010 Google Inc. All Rights Reserved. use URI::Escape; use constant GA_ACCOUNT => 'MO-XXXXXX-YY'; use constant GA_PIXEL => '/ga.pl'; sub google_analytics_get_image_url { my $url = ''; $url .= GA_PIXEL . '?'; $url .= 'utmac=' . GA_ACCOUNT; $url .= '&utmn=' . int(rand(0x7fffffff)); my $referer = $ENV{'HTTP_REFERER'}; my $query = $ENV{'QUERY_STRING'}; my $path = $ENV{'REQUEST_URI'}; if ($referer eq "") { $referer = '-'; } $url .= '&utmr=' . uri_escape($referer); $url .= '&utmp=' . uri_escape($path); © 2012 Pearson France – Google Analytics, 2e édition – Alan Boydell, Serge Descombes, Sébastien Manaches $url .= '&guid=ON'; $url =~ s/&/&/g; $url; } print '<img src="' . google_analytics_get_image_url() . '" />'; Implémentation JSP <%@ page import="java.io.UnsupportedEncodingException,java.net.URLEncoder" %> <%! // Copyright 2010 Google Inc. All Rights Reserved. private static final String GA_ACCOUNT = "MO-XXXXXX-YY"; private static final String GA_PIXEL = "/ga.jsp"; private String googleAnalyticsGetImageUrl( HttpServletRequest request) throws UnsupportedEncodingException { StringBuilder url = new StringBuilder(); url.append(GA_PIXEL + "?"); url.append("utmac=").append(GA_ACCOUNT); url.append("&utmn=").append(Integer.toString((int) (Math.random() * 0x7fffffff))); String referer = request.getHeader("referer"); String query = request.getQueryString(); String path = request.getRequestURI(); if (referer == null || "".equals(referer)) { referer = "-"; } url.append("&utmr=").append(URLEncoder.encode(referer, "UTF-8")); if (path != null) { if (query != null) { path += "?" + query; } url.append("&utmp=").append(URLEncoder.encode(path, "UTF-8")); } url.append("&guid=ON"); return url.toString().replace("&", "&"); } %> <% String googleAnalyticsImageUrl = googleAnalyticsGetImageUrl(request); %> <img src="<%= googleAnalyticsImageUrl %>" /> Implémentation ASPX <%@ Page Language="C#" %> <script language="C#" runat="server"> // Copyright 2010 Google Inc. All Rights Reserved. © 2012 Pearson France – Google Analytics, 2e édition – Alan Boydell, Serge Descombes, Sébastien Manaches private const string GaAccount = "MO-XXXXXX-YY"; private const string GaPixel = "/ga.aspx"; private string GoogleAnalyticsGetImageUrl() { System.Text.StringBuilder url = new System.Text.StringBuilder(); url.Append(GaPixel + "?"); url.Append("utmac=").Append(GaAccount); Random RandomClass = new Random(); url.Append("&utmn=").Append(RandomClass.Next(0x7fffffff)); string referer = "-"; if (Request.UrlReferrer != null && "" != Request.UrlReferrer.ToString()) { referer = Request.UrlReferrer.ToString(); } url.Append("&utmr=").Append(HttpUtility.UrlEncode(referer)); if (HttpContext.Current.Request.Url != null) { url.Append("&utmp=").Append(HttpUtility.UrlEncode(Request.Url.PathAndQuer y)); } url.Append("&guid=ON"); return url.ToString().Replace("&", "&"); } </script> <% string googleAnalyticsImageUrl = GoogleAnalyticsGetImageUrl(); %> <img src="<%= googleAnalyticsImageUrl %>" /> 12.1.4 Résultat 12.2 Mesure d'une application mobile 12.2.1 Intérêt 12.2.2 Limites 12.2.3 Méthodologie pour iOS #import "BasicExampleAppDelegate.h" #import "GANTracker.h" // Dispatch period in seconds static const NSInteger kGANDispatchPeriodSec = 10; @implementation BasicExampleAppDelegate @synthesize window = window_; - (void)applicationDidFinishLaunching:(UIApplication *)application { // ************************************************************************* * © 2012 Pearson France – Google Analytics, 2e édition – Alan Boydell, Serge Descombes, Sébastien Manaches // PLEASE REPLACE WITH YOUR ACCOUNT DETAILS. // ************************************************************************* * [[GANTracker sharedTracker] startTrackerWithAccountID:@"UA-XXXXXX-YY" dispatchPeriod:kGANDispatchPeriodSec delegate:nil]; NSError *error; if (![[GANTracker sharedTracker] setCustomVariableAtIndex:1 name:@"iPhone1" value:@"iv1" withError:&error]) { // Handle error here } if (![[GANTracker sharedTracker] trackEvent:@"my_category" action:@"my_action" label:@"my_label" value:-1 withError:&error]) { // Handle error here } if (![[GANTracker sharedTracker] trackPageview:@"/app_entry_point" withError:&error]) { // Handle error here } [window_ makeKeyAndVisible]; } - (void)dealloc { [[GANTracker sharedTracker] stopTracker]; [window_ release]; [super dealloc]; } @end /** * The purchase was processed. associated line items We will track the transaction and its * now, but only if the purchase has been confirmed. */ - (void) processPurchase:Purchase purchase { [[GANTracker sharedTracker] addTransaction:[purchase orderId] totalPrice:[purchase totalPrice] storeName:[purchase store] totalTax:[purchase tax] shippingCost:[purchase shipping] © 2012 Pearson France – Google Analytics, 2e édition – Alan Boydell, Serge Descombes, Sébastien Manaches withError:&error]; if (error) { // Handle error } for (PurchaseItem item in [purchase items]) { [[GANTracker sharedTracker] addItem:[purchase orderId] itemSKU:[item itemSKU] itemPrice:[item price] itemCount:[item count] itemCategory:[item category] withError:&error]; if (error) { // Handle error } } if ([purchase isConfirmed]) { [[GANTracker sharedTracker] trackTransactions:&error]; } else { // The purchase was denied or failed in some way. We need to clear out // any data we've already put in the Ecommerce buffer. [[GANTracker sharedTracker] clearTransactions:&error]; } } 12.2.4 Méthodologie pour Android package com.google.android.apps.analytics.sample; import com.google.android.apps.analytics.GoogleAnalyticsTracker; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; public class TestActivity extends Activity { GoogleAnalyticsTracker tracker; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); tracker = GoogleAnalyticsTracker.getInstance(); // Start the tracker in manual dispatch mode... tracker.startNewSession("UA-XXXXX-YY", this); // ...alternatively, the tracker can be started with a dispatch interval (in seconds). //tracker.startNewSession("UA-XXXXX-YY", 20, this); © 2012 Pearson France – Google Analytics, 2e édition – Alan Boydell, Serge Descombes, Sébastien Manaches setContentView(R.layout.main); Button createEventButton = (Button)findViewById(R.id.NewEventButton); createEventButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { tracker.trackEvent( "Clicks", // Category "Button", // Action "clicked", // Label 77); // Value } }); Button createPageButton = (Button)findViewById(R.id.NewPageButton); createPageButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // Add a Custom Variable to this pageview, with name of "Medium" and value "MobileApp" and // scope of session-level. tracker.setCustomVar(1, "Navigation Type", "Button click", 2); // Track a page view. This is probably the best way to track which parts of your application // are being used. // E.g. // tracker.trackPageView("/help"); to track someone looking at the help screen. // tracker.trackPageView("/level2"); to track someone reaching level 2 in a game. // tracker.trackPageView("/uploadScreen"); to track someone using an upload screen. tracker.trackPageView("/testApplicationHomeScreen"); } }); Button quitButton = (Button)findViewById(R.id.QuitButton); quitButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { finish(); } }); Button dispatchButton = (Button)findViewById(R.id.DispatchButton); dispatchButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { © 2012 Pearson France – Google Analytics, 2e édition – Alan Boydell, Serge Descombes, Sébastien Manaches // Manually start a dispatch, not needed if the tracker was started with a dispatch // interval. tracker.dispatch(); } }); } @Override protected void onDestroy() { super.onDestroy(); // Stop the tracker when it is no longer needed. tracker.stopSession(); } } 12.2.5 Résultat Chapitre 13 © 2012 Pearson France – Google Analytics, 2e édition – Alan Boydell, Serge Descombes, Sébastien Manaches Autres cas pratiques 13.1 Mesure de la notoriété de votre marque 13.1.1 Intérêt 13.1.2 Limites 13.1.3 Méthodologie 13.1.4 Résultat 13.2 Mesure d'un seul site dans deux comptes Google Analytics différents 13.2.1 Intérêt 13.2.2 Limites 13.2.3 Méthodologie 13.2.4 Résultat 13.3 Intégration des données Google Website Optimizer dans Google Analytics 13.3.1 Intérêt 13.3.2 Limites 13.3.3 Méthodologie <script type="text/JavaScript"> var combination = utmx("combination"); var content = utmx("combination_string"); var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-XXXXX-X']); _gaq.push(['_setCustomVar',1,"Version Website Optimizer", combination+" "+content,1]); _gaq.push(['_trackPageview']); _gaq.push(['gwoTracker._setAccount', 'UA-XXXXX-Y']); _gaq.push(['gwoTracker._trackPageview','/9999999999/test']); © 2012 Pearson France – Google Analytics, 2e édition – Alan Boydell, Serge Descombes, Sébastien Manaches (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> 13.3.4 Résultats 13.4 Récupération des mots clés tapés sur les comparateurs de prix 13.4.1 Intérêt 13.4.2 Limites 13.4.3 Méthodologie <script type="text/JavaScript"> var _gaq = _gaq || []; _gaq.push(['_setAccount','UA-XXXXXX-X']); _gaq.push(['_addOrganic','kelkoo', 'contextKeywords']); _gaq.push(['_addOrganic','leguide', 'ms']); _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> <script type="text/JavaScript"> var _gaq = _gaq || []; _gaq.push(['_setAccount','UA-XXXXXX-1']); _gaq.push(['_addOrganic','exalead', 'q']); _gaq.push(['_trackPageview']); _gaq.push(['t2._setAccount','UA-XXXXXX-2']); _gaq.push(['t2._addOrganic','kelkoo', 'contextKeywords']); _gaq.push(['t2._addOrganic','leguide', 'ms']); _gaq.push(['t2._trackPageview']); (function() { © 2012 Pearson France – Google Analytics, 2e édition – Alan Boydell, Serge Descombes, Sébastien Manaches 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> 13.4.4 Résultat 13.5 Récupération de l'intégralité des referers dans un profil dédié 13.5.1 Intérêt 13.5.2 Limites 13.5.3 Méthodologie ^https?://(?![^/]*monsite\.fr)(.*) 13.5.4 Résultats 13.6 Importation de données de Google Analytics dans une Data Warehouse 13.6.1 Intérêt 13.6.2 Limites 13.6.3 Méthodologie <script type="text/JavaScript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-XXXXXX-X']); _gaq.push(['_setCustomVar', 1, 'UserId', '1234', 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> © 2012 Pearson France – Google Analytics, 2e édition – Alan Boydell, Serge Descombes, Sébastien Manaches 13.6.4 Résultats Annexe A Outils indispensables Consulter les cookies posés par Google Analytics Extension Edit this cookie de Chrome Autres possibilités de lecture Analyser les requêtes GIF Deux logiciels : Fiddler et Charles Les fonctionnalités intégrées au navigateur : console Chrome et Firebug Amélioration de la console Chrome avec l’extension Google Analytics Debugger Améliorer ses expressions régulières Deux logiciels : Regex Coach et RegExr Des outils en ligne © 2012 Pearson France – Google Analytics, 2e édition – Alan Boydell, Serge Descombes, Sébastien Manaches Annexe B Variables utm © 2012 Pearson France – Google Analytics, 2e édition – Alan Boydell, Serge Descombes, Sébastien Manaches Annexe C Principales fonctions de Google Analytics Configuration de base _setAccount () _setAccount(accountId) Accepte comme arguments _gaq.push(['_setAccount', 'UA-1234-1']); _setDomainName() _setDomainName(domaineDeVotreChoix) Accepte comme arguments _gaq.push(['_setDomainName','.monSite.com']); Suivi des pages vues et des événements _trackPageview () _trackPageview(URIdePage_Optionnelle) Accepte comme arguments _gaq.push(['_setAccount', 'UA-12345-1']); _gaq.push(['_trackPageview', '/repertoire/monNomDePage.html']); _trackEvent() _trackEvent(categorie, action, label_optionnel, valeur_optionnelle, nonInteractionnel_optionnel) Accepte comme arguments Renvoie _gaq.push(['_trackEvent', 'Videos', 'Play', 'We are Four Lions']); _trackSocial() _trackSocial(réseau, action, cible_optionnelle, UriDePage_optionnelle) Accepte comme arguments _gaq.push(['_trackSocial', 'facebook', 'like', 'http://monsite.fr/monProduitPhare.html']); © 2012 Pearson France – Google Analytics, 2e édition – Alan Boydell, Serge Descombes, Sébastien Manaches Personnalisation des cookies _setSessionCookieTimeout() _setSessionCookieTimeout(duréeDeVieDuCookieEnMillisecondes) Accepte comme arguments _gaq.push(['_setSessionCookieTimeout', 45*60*1000]); //durée de session de 45 minutes _setVisitorCookieTimeout() _setVisitorCookieTimeout(duréeDeVieDuCookieEnMillisecondes) Accepte comme arguments _gaq.push(['_setSessionCookieTimeout', 365*24*60*60*1000 ]); unique reconnu sur un an //visiteur _setCampaignCookieTimeout() _setCampaignCookieTimeout(duréeDeVieDuCookieEnMillisecondes) Accepte comme arguments _gaq.push(['_setSessionCookieTimeout', 30*24*60*60*1000 ]); retenue pendant 30 jours //source _setCookiePath() _setCookiePath(nouveauRépertoire) Accepte comme arguments pageTracker._setCookiePath("/questions-reponses-web-analytics/"); _setDomainName() _setDomainName(domaineDeVotreChoix) Accepte comme arguments _gaq.push(['_setDomainName','.monSite.com']); Segments personnalisés _setCustomVar() _setCustomVar(index,nom,valeur,champdApplication_Optionnel) Renvoie Accepte comme arguments _gaq.push(['_setCustomVar', 1, 'Catégorie_de_page', ' FAQ', 3]); © 2012 Pearson France – Google Analytics, 2e édition – Alan Boydell, Serge Descombes, Sébastien Manaches _getVisitorCustomVar() _getVisitorCustomVar(index) Accepte comme arguments Renvoie _gaq.push(function() { var pageTracker = _gat._getTrackerByName(); var valeur = pageTracker._getVisitorCustomVar(1); //Index 1 }); _deleteCustomVar() _deleteCustomVar(index) Accepte comme arguments _gaq.push(['_deleteCustomVar', 1]); //Index 1 Configuration domaines _setDomainName() _setDomainName(domaineDeVotreChoix) Accepte comme arguments _gaq.push(['_setDomainName','.monSite.com']); _link() _link(URLcible, ancre_optionnel) Accepte comme arguments <a href="http://www.nouveau-site.com" onclick="_gaq.push(['_link', 'http://www.nouveau-site.com']); return false;">Cliquez ici pour voir notre mini-site !</a> _linkByPost() _linkByPost(objetFormulaire, ancre_optionnel) Accepte comme arguments <form action="http://www.shoppingcartsite.com/myService/formProcessor.php" name="f" method="post" onsubmit="_gaq.push(['_linkByPost', this]);"> . . . </form> _setAllowLinker() _setAllowLinker(valeurBooléenne) © 2012 Pearson France – Google Analytics, 2e édition – Alan Boydell, Serge Descombes, Sébastien Manaches Accepte comme arguments _gaq.push(['_setAllowLinker', true]); _getLinkerUrl() _getLinkerUrl(URLcible, ancre_optionnel) Accepte comme arguments _gaq.push(function() { var pageTracker = _gat._getTrackerByName(); var linkerUrl = pageTracker._getLinkerUrl('http://exemple.com/pagecible.html'); }); Suivi de l'e-commerce _addItem() _addItem(idCommande, idProduit, nom, categorie, prix, quantité) Accepte comme arguments _gaq.push(['_addItem', "1234", "DD44", "Vetements", "Pantalon noir", "11.99", "1" ]); _addTrans() _addTrans(idCommande, affiliation, total, taxes, livraison, ville, région, pays) _gaq.push(['_addTrans', "1234", "", "20.00", "3.01","5.00","","","" ]); Accepte comme arguments _trackTrans() _trackTrans() _gaq.push(['_trackTrans']); Moteurs de recherche et sites référents _addOrganic() _addOrganic(nouveauMoteur, paramètreDeMotClé, optionDePrétraitement_optionel, nomDAffichage_optionel) Accepte comme arguments _gaq.push(['libero.it', 'query', false, 'libero')] _addIgnoredOrganic() _addIgnoredOrganic(nouveauMotCléAIgnorer) © 2012 Pearson France – Google Analytics, 2e édition – Alan Boydell, Serge Descombes, Sébastien Manaches Accepte comme arguments _gaq.push(['_addIgnoredOrganic', 'www.monSite.com']); _addIgnoredRef() _addIgnoredRef(nouveauSiteRéférentAIgnorer) Accepte comme arguments _gaq.push(['_addIgnoredRef', 'www.monAutreSite.com']); _setReferrerOverride() _setReferrerOverride(newReferrerUrl) Accepte comme arguments _gaq.push(['_setReferrerOverride', 'http://www.google.com/?q=monSite' ]); Suivi des campagnes _setAllowAnchor() _setAllowAnchor(valeurBooléenne) Accepte comme arguments _gaq.push(['_setAllowAnchor', true]); _setCampContentKey() _setCampContentKey(nouveauParamètreDeContenuDeCampagne) Accepte comme arguments _gaq.push(['_setCampContentKey', "crea" ]); _setCampMediumKey() _setCampMediumKey(nouveauParamètreDeSupportDeCampagne) Accepte comme arguments _gaq.push(['_setCampMediumKey', "type" ]); _setCampNameKey() _setCampNameKey(nouveauParamètreDuNomDeCampagne) Accepte comme arguments _gaq.push(['_setCampNameKey', "name" ]); _setCampSourceKey() _setCampSourceKey(nouveauParamètreDeSourceDeCampagne) © 2012 Pearson France – Google Analytics, 2e édition – Alan Boydell, Serge Descombes, Sébastien Manaches Accepte comme arguments _gaq.push(['_setCampSourceKey', "source" ]); _setCampTermKey() _setCampTermKey(nouveauParamètreDeMotCléDeCampagne) Accepte comme arguments _gaq.push(['_setCampTermKey', "motcle" ]); _setCampaignCookieTimeout() _setCampaignCookieTimeout(duréeDeVieDuCookieEnMillisecondes) Accepte comme arguments _gaq.push(['_setSessionCookieTimeout', 30*24*60*60*1000 ]); retenue pendant 30 jours //source © 2012 Pearson France – Google Analytics, 2e édition – Alan Boydell, Serge Descombes, Sébastien Manaches