diff --git a/website/docs/docusaurus-core.md b/website/docs/docusaurus-core.md index d5c78ea5809b..30751f4ef2ba 100644 --- a/website/docs/docusaurus-core.md +++ b/website/docs/docusaurus-core.md @@ -298,6 +298,26 @@ const MyComponent = () => { }; ``` +### `onRouteUpdate({location})` + +If the current rendering environment is on client i.e. `ExecutionEnvironment.canUseDOM === true`, then `onRouteUpdate({location})` updates the Google Analytics plugin +by setting the page value to current path, inorder to measure the number of views one had for a particular page on the website. +Recommended for Single-page Applications. + +Usage example: + +```jsx {2,5,6,7} +import React from 'react'; +import {onRouteUpdate} from '@docusaurus/useGlobalData'; + +const MyComponent = () => { + const location = { pathname:'./example.html' }; + + onRouteUpdate({location}); + return