Skip to content

Commit

Permalink
feat: ✨ GA hook file added
Browse files Browse the repository at this point in the history
  • Loading branch information
k-t18 committed Oct 1, 2024
1 parent 65993dd commit b56ee4f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
14 changes: 14 additions & 0 deletions hooks/GoogleAnalytics/useGoogleAnalyticsHandler.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { useEffect } from 'react';
import ReactGA from 'react-ga';

const useGoogleAnalyticsHandler = () => {
const TRACKING_ID: string | undefined = process.env.NEXT_PUBLIC_GOOGLE_ANALYTICS_TRACKING_CODE;
if (TRACKING_ID) {
ReactGA.initialize(TRACKING_ID);
} else {
console.error('You have enabled Google Analytics but tracking ID is not specified. Please add Tracking ID!');
}
return {};
};

export default useGoogleAnalyticsHandler;
1 change: 1 addition & 0 deletions services/config/app-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@ export const CONSTANTS = {
DEFAULT_CURRENCY_VALUE: 'rupee',
DEFAULT_LANGUAGE: 'en',
ENABLE_SHOP_ON_AMAZON: false,
ENABLE_GOOGLE_ANALYTICS: false,
};

0 comments on commit b56ee4f

Please sign in to comment.