Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit 4428a52

Browse files
authored
Merge pull request #221 from GSA/cb_add-DAP-code
Add DAP code via injection
2 parents 280bbe7 + 5ccc67b commit 4428a52

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

index.html

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,16 +113,22 @@
113113
loadScript('<%= PUBLIC_PATH %>polyfills/custom-event.js');
114114
}
115115

116-
function injectScript(innerHTML) {
116+
function injectScript(innerHTML, type, src, id) {
117117
var script = document.createElement('script');
118118
script.innerHTML = innerHTML;
119+
script.type = type;
120+
script.src = src;
121+
script.id = id;
119122
document.head.appendChild(script);
120123
}
121124

122125
<% if (ENABLE_GOOGLE_ANALYTICS === true) { %>
123126
setTimeout(function() {
124-
//Google Tag Manager
125-
injectScript("(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src='https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);})(window,document,'script','dataLayer','GTM-5CKH6WC');");
127+
// We use Google Tag Manager to track events on code.gov
128+
injectScript("(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src='https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);})(window,document,'script','dataLayer','GTM-5CKH6WC');", "", "", "");
129+
130+
// We participate in the US government's analytics program (DAP). You can see the data for code.gov and other federal websites at analytics.usa.gov.
131+
injectScript("", "text/javascript", "https://dap.digitalgov.gov/Universal-Federated-Analytics-Min.js?agency=GSA", "_fed_an_ua_tag");
126132
}, 3000);
127133
<% } %>
128134
</script>

0 commit comments

Comments
 (0)