Wawasan Google PageSpeed ​​vs. Google Analytics

Alat validasi kayata Layanan Validasi Markup W3C utawa Google PageSpeed ​​Insights migunani kanggo ngevaluasi kode lan kinerja situs web kanthi objektif. Google khusus mengaruhi kabeh industri kanthi konsep kayata ing ndhuwur lempeng - lan uga menehi pandhuan sing ketat nanging migunani kanggo kompresi gambar lan cache. Nanging bisa kedadeyan yen Google mlaku dhewe.


Bakal kode pelacakan JavaScript

  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

  ga('create', 'UA-12350231-1', 'auto');
  ga('send', 'pageview');

Integrasi karo Google Analytics ing situs web kaya sing wis diterangake kanthi resmi , Google sambat amarga ora ana cache browser:

Wawasan Google PageSpeed ​​vs. Google Analytics

Nanging, sacara teknis mung host file, ing kasus iki Google dhewe, sing bisa mbenerake iki lan mung bisa ndandani kanthi solusi ing ngisor iki: Pisanan URL sampeyan

(window,document,'script','//www.google-analytics.com/analytics.js','ga');

menyang server sampeyan dhewe

(window,document,'script','analytics.js','ga');

lan nyiyapake tugas cron sederhana liwat PHP, sing ndownload file .js paling anyar kanthi anyar menyang server dhewe saben dina:

file_put_contents("analytics.js", fopen("https://www.google-analytics.com/analytics.js", 'r'));

Banjur sampeyan bisa nyetel cache supaya PageSpeed ​​ora ngritik kesalahan kasebut maneh:

Wawasan Google PageSpeed ​​vs. Google Analytics

Bali