I\'m on a quest to reach 100/100 on PageSpeed and i\'m almost there. I\'m trying to find a good solution to cache Google Analytics.
Here is the message I get:
Depending on your use of Google Analytics data, if you want basic information (such as visits, UI interactions) you might be able to not include analytics.js at all, yet still collect data in GA.
One option may be to instead use the measurement protocol in a cached script. Google Analytics: Measurement Protocol Overview
When you set the transport method explicitly to image, you can see how GA constructs its own image beacons.
ga('set', 'transport', 'image');
https://www.google-analytics.com/r/collect
?v={protocol-version}
&tid={tracking-id}
&cid={client-id}
&t={hit-type}
&dl={location}
You could create your own GET or POST requests with the required payload.
However, if you require a greater level of detail it probably won't be worth your effort.