How to use the analytics.tracks function in analytics

To help you get started, we’ve selected a few analytics examples, based on popular ways it is used in public projects.

github Automattic / wp-calypso / client / lib / dss / image-store.js View on Github external
return Object.assign( {}, state, { isLoading: false, lastKey: null } );

		case ActionTypes.DSS_UPDATE_IMAGES:
			if ( state.imageResultsByKey[ action.searchTerm ] ) {
				return Object.assign( {}, state, { isLoading: false, lastKey: action.searchTerm } );
			}
			debug( 'tried to update dynamic-screenshots image, but no cached data found for', action.searchTerm );
			return Object.assign( {}, state, { isLoading: false } );

		case ActionTypes.DSS_RECEIVE_IMAGES:
			const images = get( action, 'data.images', [] );
			if ( images.length < 1 ) {
				// TODO: notify the user of the error
				debug( 'error getting dynamic-screenshots images', action );

				analytics.tracks.recordEvent( 'calypso_dss_fetch_error', { searchterm: action.searchTerm } );

				return Object.assign( {}, state, { isLoading: false } );
			}
			debug( 'saving image results for', action.searchTerm );
			const imageResultsByKey = Object.assign( {}, state.imageResultsByKey, { [ action.searchTerm ]: images[0] } );

			analytics.tracks.recordEvent( 'calypso_dss_fetch_images', Object.assign( {}, { searchterm: action.searchTerm }, imageResultsByKey[ action.searchTerm ] ) );

			return Object.assign( {}, state, { isLoading: false, lastKey: action.searchTerm, imageResultsByKey } );
	}
	return state;
}, initialState );
github Automattic / wp-calypso / client / signup / steps / dss / theme-thumbnail.jsx View on Github external
handleSubmit() {
		analytics.tracks.recordEvent( 'calypso_dss_select_theme', {
			theme: this.props.themeRepoSlug,
			search_term: this.props.lastSearchTerm,
		} );

		SignupActions.submitSignupStep( { stepName: this.props.stepName }, null, {
			theme: this.props.themeRepoSlug,
			images: this.props.dssImage ? [ this.props.dssImage ] : undefined
		} );

		this.props.goToNextStep();
	},
github Automattic / wp-calypso / client / my-sites / stats / nux / site.jsx View on Github external
clickPostLink: function( event ) {
		var site = this.props.sites.getSite( this.props.siteId );
		analytics.tracks.recordEvent( 'calypso_stats_post_click' );
		event.preventDefault();
		page( '/post/' + site.slug );
	},
github Automattic / wp-calypso / client / my-sites / stats / nux / insights.jsx View on Github external
clickPostLink: function( event ) {
		event.preventDefault();
		analytics.tracks.recordEvent( 'calypso_stats_post_click' );
		page( '/post/' + this.props.site.slug );
	},
github Automattic / wp-calypso / client / signup / steps / theme-selection / theme-thumbnail.jsx View on Github external
handleSubmit: function() {
		var themeSlug = this.props.themeSlug;

		if ( true === this.props.useHeadstart && themeSlug ) {
			analytics.tracks.recordEvent( 'calypso_signup_theme_select', { theme: themeSlug, headstart: true } );

			SignupActions.submitSignupStep( { stepName: this.props.stepName }, null, {
				theme: 'pub/' + themeSlug,
				images: undefined
			} );
		} else {
			analytics.tracks.recordEvent( 'calypso_signup_theme_select', { theme: themeSlug, headstart: false } );

			SignupActions.submitSignupStep( {
				stepName: this.props.stepName,
				processingMessage: this.translate( 'Adding your theme' ),
				themeSlug
			} );
		}

		this.props.goToNextStep();
	},
github Automattic / wp-calypso / client / me / purchases / cancel-purchase / support-box.jsx View on Github external
trackClickContactSupport() {
		analytics.tracks.recordEvent(
			'calypso_purchases_click_contact_support',
			{ product_slug: this.props.purchase.productSlug }
		);
	},
github Automattic / wp-calypso / client / me / purchases / confirm-cancel-purchase / index.jsx View on Github external
notices.error( error.message || this.translate( 'Unable to cancel your purchase. Please try again later or contact support.' ) );

			return;
		}

		const purchase = getPurchase( this.props ),
			purchaseName = getName( purchase );

		notices.success(
			this.translate( '%(purchaseName)s was successfully cancelled and refunded.', {
				args: { purchaseName }
			} ), { persistent: true } );

		clearPurchases();

		analytics.tracks.recordEvent(
			'calypso_purchases_cancel_form_submit',
			{ product_slug: getPurchase( this.props ).productSlug }
		);

		page.redirect( paths.list( this.props.selectedSite.slug ) );
	},
github Automattic / wp-calypso / client / my-sites / stats / nux / site.jsx View on Github external
buildPromo: function() {
		var promo,
			site = this.props.sites.getSite( this.props.siteId ),
			queryDate = this.props.date.format( 'YYYY-MM-DD' );

		analytics.tracks.recordEvent( 'calypso_stats_post_view' );
		promo = (
			<div className="module-list">
				<div className="module-column">
					<div className="module-overlay"></div>
					<Countries path={ 'countries' } site={ site } dataList={ this.props.countriesList } period={ this.props.period } date={ queryDate } />
				</div>
				<div className="module-column">
					<h1 className="stats-section-title">{ this.translate( 'Want to learn more about how your content performs?' ) }</h1>
					<p className="stats-section-blurb">{ this.translate( 'Attract visitors from around the globe.' ) }</p>
					<button className="button is-primary" onClick={ this.clickPostLink }>{ this.translate( 'Write a Post' ) }</button>
				</div>
			</div>
		);

		return promo;
	},
github Automattic / wp-calypso / client / my-sites / stats / nux / insights.jsx View on Github external
buildPromo: function() {
		var content;

		analytics.tracks.recordEvent( 'calypso_stats_post_view' );
		content = (
			<div className="module-list">
				<div className="module-column">
					<div className="module-overlay"></div>
					<MostPopular insightsList={ this.props.insightsList } />
				</div>
				<div className="module-column">
					<h1 className="stats-section-title">{ this.translate( 'Want to learn more about how your content performs?' ) }</h1>
					<p className="stats-section-blurb">{ this.translate( 'Attract new views, likes, and comments.' ) }</p>
					<button className="button is-primary" onClick={ this.clickPostLink }>{ this.translate( 'Write a Post' ) }</button>
				</div>
			</div>
			);

		return content;
	},

analytics

Lightweight analytics library for tracking events, page views, & identifying users. Works with any third party analytics provider via an extendable plugin system.

MIT
Latest version published 6 months ago

Package Health Score

85 / 100
Full package analysis

Similar packages