Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Analytics: Add tracks to checklist CTAs #12449

Merged
merged 2 commits into from
May 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions _inc/client/my-plan/my-plan-header/checklist-cta.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@ import { translate as __ } from 'i18n-calypso';
*/
import Button from 'components/button';

export default function ChecklistCta( { siteSlug } ) {
export default function ChecklistCta( { onClick, siteSlug } ) {
return (
<div className="jp-landing__plan-features-header-checklist-cta-container">
<Button primary href={ `https://wordpress.com/plans/my-plan/${ siteSlug }` }>
<Button
href={ `https://wordpress.com/plans/my-plan/${ siteSlug }` }
onClick={ onClick }
primary
>
{ __( 'View your setup checklist' ) }
</Button>
</div>
Expand Down
73 changes: 46 additions & 27 deletions _inc/client/my-plan/my-plan-header/checklist-progress-card/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,47 +2,66 @@
* External dependencies
*/
import { translate as __ } from 'i18n-calypso';
import React from 'react';
import React, { Component } from 'react';
import { connect } from 'react-redux';

/**
* Internal dependencies
*/
import analytics from 'lib/analytics';
import Button from 'components/button';
import Card from 'components/card';
import ProgressBar from './progress-bar';
import QueryChecklistProgress from 'components/data/query-checklist-progress';
import { getSiteRawUrl } from 'state/initial-state';
import { getChecklistCompletion } from 'state/checklist/selectors';

function ChecklistProgressCard( { completed, total, siteSlug } ) {
return (
<>
<QueryChecklistProgress />
{ completed && total && (
<Card compact className="checklist__header">
<div className="checklist__header-main">
<div className="checklist__header-progress">
<span className="checklist__header-progress-text">
{ __( 'Your Jetpack setup progress', {
comment: 'Onboarding task list progress',
class ChecklistProgressCard extends Component {
trackCtaClick = () =>
void analytics.tracks.recordEvent(
'jetpack_myplan_progresschecklistcta_click',
this.props.plan
? {
plan: this.props.plan,
}
: undefined
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we always return a plan, even for free users?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should, in theory. However, I don't trust that the plan prop will always be correctly provided.

);

render() {
const { completed, total, siteSlug } = this.props;
return (
<>
<QueryChecklistProgress />
{ completed && total && (
<Card compact className="checklist__header">
<div className="checklist__header-main">
<div className="checklist__header-progress">
<span className="checklist__header-progress-text">
{ __( 'Your Jetpack setup progress', {
comment: 'Onboarding task list progress',
} ) }
</span>
<span className="checklist__header-progress-number">{ `${ completed }/${ total }` }</span>
</div>
<ProgressBar total={ total } value={ completed } />
</div>
<div className="checklist__header-secondary">
<Button
compact
href={ `https://wordpress.com/plans/my-plan/${ siteSlug }` }
onClick={ this.trackCtaClick }
primary
>
{ __( 'Complete Jetpack Setup', {
comment: 'Text on link to list of onboarding tasks',
} ) }
</span>
<span className="checklist__header-progress-number">{ `${ completed }/${ total }` }</span>
</Button>
</div>
<ProgressBar total={ total } value={ completed } />
</div>
<div className="checklist__header-secondary">
<Button compact primary href={ `https://wordpress.com/plans/my-plan/${ siteSlug }` }>
{ __( 'Complete Jetpack Setup', {
comment: 'Text on link to list of onboarding tasks',
} ) }
</Button>
</div>
</Card>
) }
</>
);
</Card>
) }
</>
);
}
}

export default connect( state => {
Expand Down
28 changes: 19 additions & 9 deletions _inc/client/my-plan/my-plan-header/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
*/
import React from 'react';
import { translate as __ } from 'i18n-calypso';
import analytics from 'lib/analytics';
import { getPlanClass } from 'lib/plans/constants';
import { connect } from 'react-redux';

/**
* Internal dependencies
*/
import analytics from 'lib/analytics';
import ChecklistCta from './checklist-cta';
import ChecklistProgress from './checklist-progress-card';
import { getPlanClass } from 'lib/plans/constants';
import { getUpgradeUrl, getSiteRawUrl, showBackups } from 'state/initial-state';
import { imagePath } from 'constants/urls';

Expand All @@ -24,10 +24,20 @@ class MyPlanHeader extends React.Component {
} );
};

trackChecklistCtaClick = () =>
void analytics.tracks.recordEvent(
'jetpack_myplan_headerchecklistcta_click',
this.props.plan
? {
plan: this.props.plan,
}
: undefined
);

render() {
const { siteSlug } = this.props;
const { plan, siteSlug } = this.props;
let planCard = '';
switch ( getPlanClass( this.props.plan ) ) {
switch ( getPlanClass( plan ) ) {
case 'is-free-plan':
planCard = (
<div className="jp-landing__plan-card">
Expand All @@ -45,7 +55,7 @@ class MyPlanHeader extends React.Component {
<p className="jp-landing__plan-features-text">
{ __( 'Get started with hassle-free design, stats, and performance tools.' ) }
</p>
<ChecklistCta siteSlug={ siteSlug } />
<ChecklistCta onClick={ this.trackChecklistCtaClick } siteSlug={ siteSlug } />
</div>
</div>
);
Expand Down Expand Up @@ -74,7 +84,7 @@ class MyPlanHeader extends React.Component {
{ __( 'Spam filtering and priority support.' ) }
</p>
) }
<ChecklistCta siteSlug={ siteSlug } />
<ChecklistCta onClick={ this.trackChecklistCtaClick } siteSlug={ siteSlug } />
</div>
</div>
);
Expand All @@ -99,7 +109,7 @@ class MyPlanHeader extends React.Component {
'Full security suite, marketing and revenue automation tools, unlimited video hosting, and priority support.'
) }
</p>
<ChecklistCta siteSlug={ siteSlug } />
<ChecklistCta onClick={ this.trackChecklistCtaClick } siteSlug={ siteSlug } />
</div>
</div>
);
Expand All @@ -124,7 +134,7 @@ class MyPlanHeader extends React.Component {
'Full security suite, marketing and revenue automation tools, unlimited video hosting, unlimited themes, enhanced search, and priority support.'
) }
</p>
<ChecklistCta siteSlug={ siteSlug } />
<ChecklistCta onClick={ this.trackChecklistCtaClick } siteSlug={ siteSlug } />
</div>
</div>
);
Expand All @@ -145,7 +155,7 @@ class MyPlanHeader extends React.Component {
return (
<>
<div>{ planCard }</div>
<ChecklistProgress />
<ChecklistProgress plan={ plan } />
</>
);
}
Expand Down