# Next Script for Google Analytics
> Prefer `next/script` component when using the inline script for Google Analytics.
### Why This Error Occurred
An inline script was used for Google analytics which might impact your webpage's performance.
### Possible Ways to Fix It
#### Using gtag.js
If you are using the [gtag.js](https://developers.google.com/analytics/devguides/collection/gtagjs) script to add analytics, use the `next/script` component with the right loading strategy to defer loading of the script until necessary.
```jsx
import Script from 'next/script'
function Home() {
return (
)
}
export default Home
```
#### Using analytics.js
If you are using the [analytics.js](https://developers.google.com/analytics/devguides/collection/analyticsjs) script to add analytics:
```jsx
import Script from 'next/script'
function Home() {
return (
)
}
export default Home
```
If you are using the [alternative async variant](https://developers.google.com/analytics/devguides/collection/analyticsjs#alternative_async_tag):
```jsx
import Script from 'next/script'
function Home() {
return (
)
}
export default Home
```
### Useful Links
- [Add analytics.js to Your Site](https://developers.google.com/analytics/devguides/collection/analyticsjs)
- [Efficiently load third-party JavaScript](https://web.dev/efficiently-load-third-party-javascript/)
- [next/script Documentation](https://nextjs.org/docs/basic-features/script)