Skip to content

Instantly share code, notes, and snippets.

@googleanalyticsresoneo
Last active September 25, 2015 18:18
Show Gist options
  • Save googleanalyticsresoneo/964266 to your computer and use it in GitHub Desktop.
Save googleanalyticsresoneo/964266 to your computer and use it in GitHub Desktop.
Marquage GA asynchrone complet pour projet SEO marché français
<!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
<!-- a la fin du head -->
<script type="text/javascript">
/*! marquage GA asynchrone de base pour projets SEO en France (c) analytics (chez) resoneo (point) com - 2013
fork it on https://gist.github.com/googleanalyticsresoneo/964266
*/
/* moteurs déjà présents dans ga.js 5.3.8
var Ld = "daum:q eniro:search_word naver:query pchome:q images.google:q google:q yahoo:p yahoo:q msn:q bing:q aol:query aol:q lycos:q lycos:query ask:q netscape:query cnn:query about:terms mamma:q voila:rdata virgilio:qs live:q baidu:wd alice:qs yandex:text najdi:q seznam:q rakuten:qt biglobe:q goo.ne:MT wp:szukaj onet:qt yam:k kvasir:q ozu:q terra:query rambler:query conduit:q babylon:q search-results:q avg:q comcast:q incredimail:q startsiden:q go.mail.ru:q search.centrum.cz:q".split(" "),
*/
/* Tout ce code peut être intégralement placé dans un JS externe chargé de préférence dans le head */
var _gaq = _gaq || [];
var pluginUrl = '//www.google-analytics.com/plugins/ga/inpage_linkid.js';
/* Moteurs de recherche complémentaires
FIXME : rattacher les moteurs utilisant les résultats google / yahoo au moteur parent
*/
_gaq.push(['_addOrganic', 'cuil', 'q', true],
['_addOrganic', 'cluuz', 'q', true],
['_addOrganic', 'alot', 'q', true, 'google'],
['_addOrganic', 'claro-search', 'q', true],
['_addOrganic', 'searchmobileonline', 'q', true],
['_addOrganic', 'snap.do', 'q', true, 'bing'],
['_addOrganic', 'certified-toolbar', 'q', true, 'bing'],
['_addOrganic', 'infospace', 'q', true],
['_addOrganic', 'webplayer.tv', 'q', true],
['_addOrganic', 'iadah', 'q', true],
['_addOrganic', 'wananow', 'query', true],
['_addOrganic', 'zapmeta', 'q', true],
['_addOrganic', 'wow', 'q', true],
['_addOrganic', 'page-accueil.net', 'q', true],
['_addOrganic', 'ask', 'searchfor', true],
['_addOrganic', 'inbox', 'q', true],
['_addOrganic', 'inbox', 'qkw', false],
['_addOrganic', 'gnoosi.net', 'q', true],
['_addOrganic', 'trouver.fr', 'q', true],
['_addOrganic', 'chercheur.be', 'q', true],
['_addOrganic', 'rapidfinder', 'q', true],
['_addOrganic', 'recherche-webs', 'q', true, 'google'],
['_addOrganic', 'glarysoft', 'q', true],
['_addOrganic', 'rpidity', 'q', true],
['_addOrganic', 'softonic', 'q', true],
['_addOrganic', 'searchcompletion', 'q', true],
['_addOrganic', 'isearch', 'q', true],
['_addOrganic', 'incredibar', 'q', true],
['_addOrganic', 'speedbit', 'q', true],
['_addOrganic', 'searchya', 'q', true],
['_addOrganic', 'protectedsearch', 'q', true],
['_addOrganic', 'similarsitesearch', 'url', true, 'site similaire, via opendns.com'],
['_addOrganic', 'opendns', 'url', true],
['_addOrganic', 'website-unavailable', 'url', true, 'site non disponible, via opendns.com'],
['_addOrganic', 'myway', 'searchfor', true],
['_addOrganic', 'mywebsearch', 'searchfor', true],
['_addOrganic', 'gooofullsearch', 'Keywords', true],
['_addOrganic', 'eo.st', 'x_query', true],
['_addOrganic', 'lo.st', 'x_query', true],
['_addOrganic', 'voila', 'kw', false],
['_addOrganic', 'lemoteur', 'kw', true, 'voila/lemoteur'],
['_addOrganic', 'presse.ke.voila', 'kw', true, 'voila/lemoteur actualité'],
['_addOrganic', 'amazon', 'query', true, 'amazon smart search', 'gp/bit/apps/web/SERP/search/'],
['_addOrganic', 'exalead', 'q', true],
['_addOrganic', 'yauba', 'q', true],
['_addOrganic', 'eazel', 'q', true],
['_addOrganic', 'yougoo', 'q', true],
['_addOrganic', 'anygator', 'q', true],
['_addOrganic', 'peeplo', 'q', true],
['_addOrganic', 'mongenie', 'keywords', true],
['_addOrganic', 'findwith.me', 'q', true],
['_addOrganic', 'ustart', 'q', true],
['_addOrganic', 'hooseek', 'recherche', true],
['_addOrganic', 'ecosia', 'q', true],
['_addOrganic', 'ecofree', 'q', true],
['_addOrganic', 'ethicle', 'q', true],
['_addOrganic', 'skynet', 'q', true],
['_addOrganic', 'globososo', 'q', true],
['_addOrganic', 'trouver.fr', 'q', true],
['_addOrganic', 'udark', 'q', true],
['_addOrganic', 'wibeez', 'q', true],
['_addOrganic', 'veosearch', 'q', true],
['_addOrganic', 'sweetim', 'q', true],
['_addOrganic', 'searcheo', 'q', true],
['_addOrganic', 'qwant', 'q', true],
['_addOrganic', 'imesh', 'q', true],
['_addOrganic', 'fastbrowsersearch', 'q', true],
['_addOrganic', 'homepa.ge', 'q', true],
['_addOrganic', 'govome', 'q', true],
['_addOrganic', 'magentic', 'q', true],
['_addOrganic', 'search.free.fr', 'q', true],
['_addOrganic', 'delta-search', 'q', true],
['_addOrganic', 'vizzeo', 'q', true],
['_addOrganic', 'bluewin.ch', 'searchTerm', true],
['_addOrganic', 'funmoods', 's', true],
['_addOrganic', 'searchfunmoods', 'q', true, 'infospace'],
['_addOrganic', 'mysearchresults', 'q', true, 'infospace'],
// fallback, moteurs avec p et q comme paramètre, groupés : false
['_addOrganic', 'toolbar', 'q', false, 'autres moteurs "search"'],
['_addOrganic', 'toolbar', 'p', false, 'autres moteurs "search"'],
['_addOrganic', 'search', 'q', false, 'autres moteurs "search"'],
['_addOrganic', 'search', 'p', false, 'autres moteurs "search"'],
['_addOrganic', 'start', 'q', false, 'autres moteurs "search"'],
['_addOrganic', 'start', 'p', false, 'autres moteurs "search"']
);
/* Variantes des moteurs Google */
_gaq.push(['_addOrganic', 'news.google', 'q', true, 'google news'],
['_addOrganic', 'google', 'q', true, 'google news', 'newssearch'],
['_addOrganic', 'google', 'rt', true, 'google news', '/news/url'],
['_addOrganic', 'google', 'q', true, 'google images', '/imgres?'],
/* url de l'image affichee comme mot clef */
['_addOrganic', 'google', 'imgurl', false, 'google recherche images', '/imgres?'],
['_addOrganic', 'maps.google', 'q', true, 'google maps'],
['_addOrganic', 'google', 'q', true, 'google maps', '/maps?'],
['_addOrganic', 'google', 'q', true, 'google custom search', '/cse?'],
['_addOrganic', 'google', 'q', true, 'google branded search', '/hws'],
['_addOrganic', 'speedfox', 'q', true, 'google'],
['_addOrganic', 'fastaddressbar', 'q', true, 'google'],
['_addOrganic', 'google', 'as_q', true], ['_addOrganic', 'google', 'as_epq', true]);
/* Google product search */
_gaq.push(['_addOrganic', 'google', 'q', true, 'google shopping', '/products/'],
['_addOrganic', 'google', 'q', true, 'google shopping', 'channel=products'],
['_addOrganic', 'google', 'q', true, 'google shopping', 'tbm=shop'],
['_addOrganic', 'google', 'q', true, 'google shopping', 'source=productsearch']);
/* Ajoute au (not provided) les moteurs qui masquent les mots clef en le passant en POST */
if (/ixquick|duckduckgo\.com|search\.free\.fr|www\.sfr\.fr|search\.iminent\.com|eannu\.com|find-asap\.com|search\.m\.orange\.fr|mongenie\.com\/search\.asp|startpage\.com\/do\/search\?/i.test(document.referrer)
&& document.referrer.split('/')[3] !== null
&& ! (/=/.test(document.referrer.split('/')[3]) )
/* exclut les campagnes payantes, expression régulière à ajuster pour les détecter, selon l'outil de tracking
* ici : Analytics, Xiti, Eulérian */
&& ! (/utm_\S+|gclid=|xtor=|ectrans=/i.test(window.location.search + window.location.hash))) {
var domc = document.referrer.split('/')[2].split('.'); // extrait le domaine
domc = domc[domc.length - 2]; // ne conserve que la composante principale du nom de domaine
_gaq.push(['_set', 'campaignParams', 'utm_campaign=(organic)&utm_medium=organic&utm_source=' + domc + '&utm_term=(not%20provided)']);
}
/* Yahoo search not passing keywords anymore , referral is
http://fr.search.yahoo.com/r/_ylt=A7x9QX64Gf5Syy4ApchjAQx.;_ylu=X3oDMTE1cjUyYXFzBHNlYwNzcgRwb3MDNgRjb2xvA2lyZAR2dGlkA01TWUZSMDRfNzc-/SIG=12ndv4t7h/EXP=1392413240/**http%3a//blog.resoneo.com/2013/11/les-top-influenceurs-sur-instagram/
liens sponso
http://fr.search.yahoo.com/r/_ylt=A7x9QaGBsA5TyDoAgAFjAQx.;_ylu=X3oDMTFlMHY0dmM0BHNlYwNvdi10b3AEY29sbwNpcmRfaW50bAR2dGlkA1ZJUEZSMDNfODYEcG9zAzE-/SIG=1iv80lc81/EXP=1393500417/**http%3a//2358460.r.msn.com/%3fld=DvAA6yGypBi1d7nh3uyrxjrTVUCUwc-TX0yW6FpZkPEg2BkBvtY4GUZ45zQI-YLzJjZOLxTHcIcBadj74zfdv8ZQK6nb-u6ZfFNPU1LJjMl8F5g-14iVN15GOK-cKbKmTHL-nXb1Gfzg7vMPghxCcQNrxfZH4%26u=ea.smartbox.com%252fdynclick%252fsmartbox-fr%252f%253fesl-k%253dsem-msn%257cn%257cc3860725765%257cme%257ck10118289505%257cp%257ct%2526eurl%253dhttp%25253A%25252F%25252Fwww.smartbox.com%25252Ffr%25252F%25253Futm_source%25253Dbing%252526utm_medium%25253Dcpc%252526utm_term%25253Dsmartbox%252526utm_content%25253DTrademark%25252520-%25252520Smartbox%252526utm_campaign%25253DCC_MSN_SEM_TM_Smartbox
*/
else if (/\/\/(\S+|\S+\.images)\.search\.yahoo\.com\/r\/_ylt/i.test(document.referrer) && ! /\d+\.r\.msn\.com\//i.test(document.referrer) &&! /[?&#]+q=[^&]+/.test(document.referrer)) {
_gaq.push(['_set', 'campaignParams', 'utm_campaign=(organic)&utm_medium=organic&utm_source=yahoo&utm_term=(not%20provided)']);
}
/* bonnes pratiques */
_gaq.push(['_setAllowAnchor', true]);
/* identification des clics sur les éléments de la page se basant sur l'ID de l'élément */
_gaq.push(['_require', 'inpage_linkid', pluginUrl]);
/* Privacy */
/* bonne pratique de privacy mais ATTENTION : l'exclusion de trafic par filtres par IP complète ou de classe D ne fonctionnera pas, n'impacte pas les exclusions de classes A,B,C */
_gaq.push(['_gat._anonymizeIp']);
/* ne pas stocker les adresses email dans GA: pas de query string du tout si on trouve un email en paramètre */
var rs_page = /\S+@\S+\.\S+/.test(window.location.search) ? document.location.pathname : document.location.pathname + window.location.search;
_gaq.push(['_set', 'page', rs_page]);
/* maximise la mesure de temps de chargement sur les pages d'entrée, notamment avec paramètres de campagne */
if (/utm_\S+|\?gclid/.test(window.location.hash + window.location.search)) {
_gaq.push(['_setSiteSpeedSampleRate', 80]);
} else {
_gaq.push(['_setSiteSpeedSampleRate', 15]);
}
/* parametres propres au compte - reprendre les paramètres actuellement utilisés */
/* mettre l'identifiant du compte - webproperty - sauf si c'est un agent de monitoring */
if (! /KHTE|KTXN|GomezAgent|AlertSite|Pingdom|YottaMonitor|evertest|ip-label|googlebot|bingpreview/gi.test(window.navigator.userAgent)) {
_gaq.push(['_setAccount', 'UA-YYYYY-XX']); // mettre votre valeur de UA
}
/* fin de la configuration de ga.js, hit de mesure de la page vue */
_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>
@googleanalyticsresoneo
Copy link
Author

nettoyage / compléments, préparation du suivi des moteurs masquant les mots clefs

@googleanalyticsresoneo
Copy link
Author

détection des moteurs français qui masquent le mot clef en le passant en POST, mot clef (not provided) dans ce cas
actualisation de la liste de moteurs
commentaires

@googleanalyticsresoneo
Copy link
Author

ajout de duckduckgo.com

@googleanalyticsresoneo
Copy link
Author

correction des priorités entre les moteurs contenant 'search'

@googleanalyticsresoneo
Copy link
Author

un peu de tri et de ménage

@googleanalyticsresoneo
Copy link
Author

encore des ajustements en beta, à suivre

@googleanalyticsresoneo
Copy link
Author

Actualisation, suppression du trafic des sondes connues par leur user-agent

@googleanalyticsresoneo
Copy link
Author

quelques moteurs en plus, et yahoo search en not provided si pas de mot clef

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment