Add google analytics scripts in template for standalone app
Signed-off-by: r.bideau <7304827+rbideau@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
---
|
||||
'@backstage/create-app': patch
|
||||
---
|
||||
|
||||
Add the google analytics scripts in the `index.html` template for new applications.
|
||||
|
||||
To apply this change to an existing application, change the following in `packages\app\public\index.html`:
|
||||
|
||||
```diff
|
||||
<title><%= app.title %></title>
|
||||
|
||||
+ <% if (app.googleAnalyticsTrackingId && typeof app.googleAnalyticsTrackingId
|
||||
+ === 'string') { %>
|
||||
+ <script
|
||||
+ async
|
||||
+ src="https://www.googletagmanager.com/gtag/js?id=<%= app.googleAnalyticsTrackingId %>"
|
||||
+ ></script>
|
||||
+ <script>
|
||||
+ window.dataLayer = window.dataLayer || [];
|
||||
+ function gtag() {
|
||||
+ dataLayer.push(arguments);
|
||||
+ }
|
||||
+ gtag('js', new Date());
|
||||
+
|
||||
+ gtag('config', '<%= app.googleAnalyticsTrackingId %>');
|
||||
+ </script>
|
||||
+ <% } %>
|
||||
</head>
|
||||
```
|
||||
@@ -48,6 +48,22 @@
|
||||
}
|
||||
</style>
|
||||
<title><%= app.title %></title>
|
||||
<% if (app.googleAnalyticsTrackingId && typeof app.googleAnalyticsTrackingId
|
||||
=== 'string') { %>
|
||||
<script
|
||||
async
|
||||
src="https://www.googletagmanager.com/gtag/js?id=<%= app.googleAnalyticsTrackingId %>"
|
||||
></script>
|
||||
<script>
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
function gtag() {
|
||||
dataLayer.push(arguments);
|
||||
}
|
||||
gtag('js', new Date());
|
||||
|
||||
gtag('config', '<%= app.googleAnalyticsTrackingId %>');
|
||||
</script>
|
||||
<% } %>
|
||||
</head>
|
||||
<body style="margin: 0;">
|
||||
<noscript>You need to enable JavaScript to run this app.</noscript>
|
||||
|
||||
Reference in New Issue
Block a user