-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #38 from vtex-apps/google-analytics
Track Page Views in Google Analytics
- Loading branch information
Showing
2 changed files
with
14 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
import React, { ReactElement, FC } from 'react' | ||
import React, { ReactElement, FC, useEffect } from 'react' | ||
import { FormattedMessage } from 'react-intl' | ||
import { Drawer } from 'vtex.store-drawer' | ||
import { Link } from 'vtex.render-runtime' | ||
|
||
import { initialize, pageview, ga } from 'react-ga' | ||
import SideBarItem from './SideBarItem' | ||
import { formatLink } from '../utils' | ||
import { useSideBarContentState } from './SideBarContext' | ||
|
@@ -15,9 +15,17 @@ interface Chapter { | |
articles: [] | Chapter[] | ||
} | ||
|
||
function pageView() { | ||
if (typeof ga() === 'undefined') { | ||
initialize('UA-150301985-1') | ||
} | ||
pageview(window.location.pathname + window.location.search) | ||
} | ||
|
||
const SideBar: FC = () => { | ||
const appName = '[email protected]' | ||
const { content } = useSideBarContentState() | ||
useEffect(() => pageView()) | ||
|
||
return ( | ||
<nav className="w-100 fixed static-l bg-base z-2 min-h-100-l br-l b--muted-3 flex-l flex-column"> | ||
|