Outils pour utilisateurs

Outils du site


Panneau latéral

webdev:api:google_shit

Ceci est une ancienne révision du document !


Google shit

Analytics Google Tag manager Google Search Console (anciennement Webmaster tools)

Google Tag Manager

The scripts included by GTM are added before the first script in the page. So with the plans de marquages where we have to put some script before the gtm js we can't make it work.

Solution : change the way the GTM js is called. The following code append the gtm into the head (it's supposed to be at the end but only goes just after the js which call it, but that still work).

(function(w,d,s,l,i)
{
	w[l]=w[l]||[];w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'});
	var f=d.getElementsByTagName('head')[0],
	j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';
	j.async=true;j.src='//www.googletagmanager.com/gtm.js?id='+i+dl;
	f.appendChild(j);
})(window,document,'script','dataLayer','GTM-XXXXXXX');

Charger analytics en asynchrone

Doc

Gmaps

AIzaSyAyHMWgqFzePVvGzc8ZxGvTfKwx3CJrLJo

webdev/api/google_shit.1555950919.txt.gz · Dernière modification: 22/04/2019 18:35 de dolo