Skip to content

Commit ad0b267

Browse files
Merge pull request #108 from DSACMS/sachin/DAP-implementation
Adding DAP Analytics
2 parents 340c81a + fb7dc69 commit ad0b267

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

index.html

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@
2525
<script src="js/formDataToJson.js"></script>
2626
<script src="js/exemptionQuizHandler.js"></script>
2727
<script src="js/autoGenerateFields.js"></script>
28+
29+
<!-- We participate in the US government's analytics program. See the data at analytics.usa.gov. -->
30+
<script async type="text/javascript" src="https://dap.digitalgov.gov/Universal-Federated-Analytics-Min.js?agency=HHS&subagency=CMS&sitetopic=metadata&siteplatform=GitHubPages" id="_fed_an_ua_tag"></script>
31+
2832
<script type="text/javascript">
2933
createFormComponents()
3034
.then((components) => {
@@ -34,11 +38,32 @@
3438
components: components,
3539
}).then(function (form) {
3640
window.formIOInstance = form;
41+
42+
// form start must only fire once
43+
let formStartFired = false;
44+
form.on("focus", function () {
45+
if (!formStartFired) {
46+
formStartFired = true;
47+
gas4('form_start', {
48+
'form_name': 'code.json form',
49+
'form_id': 'formio',
50+
'form_destination': window.location.pathname
51+
});
52+
}
53+
});
54+
3755
form.on("submit", function (submission) {
3856
console.log("Form Submission here:", submission);
3957
createCodeJson(submission.data);
58+
59+
gas4('form_submit', {
60+
'form_name': 'code.json form',
61+
'form_id': 'formio',
62+
'form_destination': window.location.pathname,
63+
'form_submit_text': 'Generate code.json metadata'
64+
});
4065
});
41-
});
66+
})
4267
})
4368
.catch((error) => {
4469
console.error("Error creating components:", error);
@@ -292,6 +317,7 @@ <h2>Complete the entire form to generate the code.json file</h2>
292317
indicates a required field</em></p>
293318
</div>
294319

320+
<!-- Generated Form -->
295321
<div id="formio"></div>
296322

297323
<!-- code.json Generated Output -->

0 commit comments

Comments
 (0)