Devendra174's picture
Upload folder using huggingface_hub
1e92f2d verified
|
raw
history blame
2.45 kB

Analytics: Google Analytics

We should use Google Analytics to record all events the user performs on a page that do not trigger a page view (this will allow us to determine bounce rate on pages).

We are using Google Analytics to monitor user flows through the Calypso user interface in order to learn where they succeed and where they fail, as well as to determine the usage of different sections.

Please do not ship anything that does not have Google Analytics tracking in place, otherwise we will create big gaps in our understanding.

Usage

In most situations, it is best to use the Analytics Middleware, which has no direct browser dependencies and therefore will not complicate any unit testing of the modules where it is used.

recordGoogleEvent( category, action [, label, value ] )

import { recordGoogleEvent } from 'calypso/state/analytics/actions';

dispatch( recordGoogleEvent( 'Reader', 'Loaded Next Page', 'page', 2 ) );

gaRecordEvent( category, action [, label, value ] ) (Deprecated)

Note: Unless you have a strong reason to call analytics.ga directly, you should use the Analytics Middleware instead.

Record an event:

import { gaRecordEvent } from 'calypso/lib/analytics/ga';

gaRecordEvent( 'Reader', 'Clicked Like' );
gaRecordEvent( 'Reader', 'Loaded Next Page', 'page', 2 );

For more information and examples about how and when to provide the optional optionLabel and optionValue parameters, refer to the Google Analytics Event Tracking documentation.

gaRecordPageView( url, title ) (Deprecated)

Note: Unless you have a strong reason to directly record a page view to Google Analytics, you should use PageViewTracker instead.

Record a virtual page view:

import { gaRecordPageView } from 'calypso/lib/analytics/ga';

gaRecordPageView( '/posts/draft', 'Posts > Drafts' );

Naming Conventions

We should categorize events by the section they are in. Examples are Posts, Pages, Reader, and Sharing.

We should write event actions in readable form, and use action-centric language. Good examples are Clicked Save Button, Clicked Like, and Activated Theme.

For page view tracking conventions, refer to the Page Views documentation.