The plugin gatsby-plugin-google-gtag adds analytics.js and gtag.js to my website. This reduces my page speed insights score. Isn't gtag.js enough ? Why do we need analytics.js ?
Why does gatsby-plugin-google-gtag includes analytics.js and gtag.js?
337 Views Asked by Simon Ludwig At
1
There are 1 best solutions below
Related Questions in PLUGINS
- Chrome/Firefox plug-in for automatically opening the dev tools and executing code in the console
- Creating a modal window in product edit page in Shopware6 and saving data to custom table(repository) from a form within the modal window
- Swiper.js moves slides outside of viewport/page
- Responsive Lightbox & Gallery issue
- Unity - How to add C++ file directly to be used as a Plug-in
- Can not switch camera while recording with camera plugin, setDescription working but preview doesn't change
- can anyone help me for NSIS Script I have a case where I need to check cases can be 3.3 3.42 23.5 23.56w 3.467 999.999 999.99a but not 1.b or 8..a
- How can I know if a vscode intelliSense suggestion is visible?
- Loader / Spinner infinite | Filter Everything Pro
- HTML Not Rendering and Displaying as Plain Text on Frontend with Ninja Forms in WordPress
- I want to run my own interface that I coded with Python in RoboDK
- How to redirect uploads from customers to go into specific folder?
- TestNG update related issue
- Co Author Plus: Need to add co authors names with link
- JS-issue "undefined query" when trying to create chrome-plugin
Related Questions in GATSBY
- Gatsby create nodes dynamically with json fetch
- gatsby + netlify cms images not loading
- tsv file at path isn't found when running locally with Gatsby
- Warning package.json: No license field $ TARGET_ENV='dev' gatsby develop
- Build errors when running gatsby build after using getServerData() for SSR page
- Gatsby - ReferenceError: Cannot access 'u' before initialization
- How to fetch all the keywords from the database in Gatsby
- Gatsby 5+ and gatsby-plugin-preact error "renderToPipeableStream is not a function"
- WebpackError: ReferenceError: document is not defined with lottie-react
- How to upload images via Gatsby Azure Static Web App into Azure Database
- Error: Inline JavaScript is not enabled - Gatsby with gatsby-plugin-less and gatsby-plugin-antd
- Gatsby hydration error on production but everything works fine locally
- Cannot find module '@reach/router' after using @gatsbyjs/reach-router
- Commenting in a Gatsby website + wordpress CMS
- gatsby-node.js file throws an error after uploading to Gatsby Azure Static Web App
Related Questions in GTAG.JS
- Remix App - Error: Minified React error #418 / #423 - on Google Analytics gtag script
- Load dataLayer Variables prior to gtag configuration in GTM
- GTM GA4 Custom HTML tag to new Google Tag - possible?
- How to perform multiple HTTP requests with unique IP addresses from my local
- (Google) Enhanced conversions aren't processed because your user email data field is incorrectly formatted
- SRI check always failing for gtag js script in browser
- How can I extract gtag( 'consent' ) values?
- Print the value fetched from javascript script in php
- How do I organize my event data to display desired metrics in one place?
- Google Tag shows up in Tag Manager and Analytics but not Google Ads
- Google Analytics event count data not accurate
- Gtag not defined when using inserted script
- Using GA4 server-side to get the client_id without an html file (server-side)
- Google Analytics with Next.Js, window.gtag is not a function
- Google tag assistant connects to domain but can't find tag
Related Questions in ANALYTICS.JS
- How can I implement analytics.js to my page and send the tracking methods to my own backend
- Migration of Universal Analytics to GA4
- How do i install GA4 on website with legecy analytics.js without having to add a second snippet
- Google analytics - Store event when GA session ends?
- Which is the best method to set up event tracking for new account signup steps in GA4?
- Add Brand To Analytics.js Ecommerce's AddTransaction?
- Bridging the gap between _gaq.push and gtag
- Migration from ga to gtag.js scripts
- Google Analytics Social Interactions via. gtag.js
- Analytics.js callback executed before library is loaded
- Why does gatsby-plugin-google-gtag includes analytics.js and gtag.js?
- Custom Campaign tracking Cross-Domain Google Analytics
- Disable automatic pageview tracking with Google Analytics analytics.js (ga)
- Implementation of ecommerce.js
- How to get E-commerce transaction ID from Google Analytics tracker
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular # Hahtags
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
It's not the Gatsby plugin that's adding
analytics.js; it's Google.I was confused by this as well when we were migrating from
gatsby-plugin-google-analyticstogatsby-plugin-google-gtag, as my expectation was to seeanalytics.jsdisappear and be replaced bygtag.jsin the built website. Instead, like you, I saw bothanalytics.jsandgtag.jsgetting loaded and thought something was wrong.It turns out that Google's current implementation of
gtag.jsis largely a wrapper around their older ("legacy", according to Google) product integration scripts likeanalytics.jsfor Google Analytics andconversion_async.jsfor Google Ads. Depending on which identifiers you feed togtag.js, it will load these other scripts, whichever ones are applicable.You can test this yourself by using your favorite ad/content blocker to stop
gtag.jsfrom loading on your website. Notice that, if you do this, the HTML to loadanalytics.jsis nowhere to be found in the page's source code. That's because it is only injected into the code later bygtag.jsat runtime, rather than by anything at Gatsby build time. Ifgtag.jsnever runs, the tag foranalytics.jsis never injected into the page.Your page speed insights score has likely decreased because
gtag.jsis a sizeable chunk of JavaScript, and then it goes and loads the same old biganalytics.jsyou were using before. One might ask, if I only use Google Analytics and none of the other products for whichgtag.jscan grab metrics, then why should I load the largegtag.jslibrary just to chainloadanalytics.jsinstead of just loadinganalytics.jsdirectly? I think there's a good argument to be made in favor of doing this, but I still favor going withgtag.jsmyself. Google themselves are heavily pushing adoption ofgtag.jsover direct calls toanalytics.js, and I don't think there's any guarantee that just becausegtag.jsis wrappinganalytics.jstoday it will still be doing so tomorrow. Basic laws of API usage apply: as a developer, I should be writing to the interface and not counting on particularities of the implementation, since those can be changed by the API provider at will as long as the interface remains stable.