Skip to content

Commit 269a876

Browse files
authored
Merge pull request code-dot-org#26935 from code-dot-org/pl-teacher-application-analytics
PL: teacher application reports GA pageviews
2 parents b8291c4 + 8e2a08f commit 269a876

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

apps/src/code-studio/pd/application/teacher1920/Teacher1920Application.jsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import Section3TeachingBackground from './Section3TeachingBackground';
66
import Section4ProfessionalLearningProgramRequirements from './Section4ProfessionalLearningProgramRequirements';
77
import Section5AdditionalDemographicInformation from './Section5AdditionalDemographicInformation';
88
import Section6Submission from './Section6Submission';
9+
/* global ga */
910

1011
export default class Teacher1920Application extends FormController {
1112
static propTypes = {
@@ -48,4 +49,13 @@ export default class Teacher1920Application extends FormController {
4849
// Let the server display a confirmation page as appropriate
4950
window.location.reload(true);
5051
}
52+
53+
/**
54+
* @override
55+
*/
56+
onSetPage(newPage) {
57+
// Report a unique page view to GA.
58+
ga('set', 'page', '/pd/application/teacher/' + newPage + 1);
59+
ga('send', 'pageview');
60+
}
5161
}

apps/src/code-studio/pd/form_components/FormController.jsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,16 @@ export default class FormController extends React.Component {
5252
}
5353

5454
componentWillMount() {
55+
let newPage;
5556
if (this.constructor.sessionStorageKey && sessionStorage[this.constructor.sessionStorageKey]) {
5657
const reloadedState = JSON.parse(sessionStorage[this.constructor.sessionStorageKey]);
5758
this.setState(reloadedState);
59+
newPage = reloadedState.currentPage;
60+
} else {
61+
newPage = this.state.currentPage;
5862
}
63+
64+
this.onSetPage(newPage);
5965
}
6066

6167
/**
@@ -168,6 +174,13 @@ export default class FormController extends React.Component {
168174
// Intentional noop; overridden by child classes
169175
}
170176

177+
/**
178+
* Called when we set a new page.
179+
*/
180+
onSetPage(newPage) {
181+
// Intentional noop; overridden by child classes
182+
}
183+
171184
/**
172185
* Submit serialized form data to the specified API Endpoint and handle server
173186
* response
@@ -400,6 +413,8 @@ export default class FormController extends React.Component {
400413
});
401414

402415
this.saveToSessionStorage({currentPage: newPage});
416+
417+
this.onSetPage(newPage);
403418
}
404419
}
405420

dashboard/app/views/pd/application/teacher_application/submitted.html.haml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,10 @@
1212
= link_to 'https://code.org/educate', 'https://code.org/educate'
1313
for additional resources and opportunities to connect with other computer science educators.
1414
Thank you for supporting computer science for all!
15+
16+
:javascript
17+
$(document).ready(function() {
18+
// Report a unique page view to GA.
19+
ga('set', 'page', '/pd/application/teacher/submitted');
20+
ga('send', 'pageview');
21+
});

0 commit comments

Comments
 (0)