diff --git a/.changeset/mighty-masks-hear.md b/.changeset/mighty-masks-hear.md new file mode 100644 index 0000000000..bb19be1420 --- /dev/null +++ b/.changeset/mighty-masks-hear.md @@ -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 + <%= app.title %> + ++ <% if (app.googleAnalyticsTrackingId && typeof app.googleAnalyticsTrackingId ++ === 'string') { %> ++ ++ ++ <% } %> + +``` diff --git a/.github/styles/vocab.txt b/.github/styles/vocab.txt index 2a8854b8a2..bf6dfb4451 100644 --- a/.github/styles/vocab.txt +++ b/.github/styles/vocab.txt @@ -204,6 +204,7 @@ octokit oidc onboarding pagerduty +pageview parallelization plantuml postgres diff --git a/docs/integrations/google-analytics/installation.md b/docs/integrations/google-analytics/installation.md new file mode 100644 index 0000000000..a0e6f69d13 --- /dev/null +++ b/docs/integrations/google-analytics/installation.md @@ -0,0 +1,24 @@ +--- +id: installation +title: Google Analytics Installation +sidebar_label: Installation +# prettier-ignore +description: Adding Google Analytics to Your App +--- + +There is a basic Google Analytics integration built into Backstage. You can +enable it by adding the following to your app configuration: + +```yaml +app: + googleAnalyticsTrackingId: UA-000000-0 +``` + +Replace the tracking ID with your own. + +For more information, learn about Google Analytics +[here](https://marketingplatform.google.com/about/analytics/). + +The default behavior is only to send a pageview hit to Google Analytics. To +record more, look at the developer documentation +[here](https://developers.google.com/analytics/devguides/collection/gtagjs). diff --git a/docs/plugins/observability.md b/docs/plugins/observability.md index 8b6668606f..de6f4bf988 100644 --- a/docs/plugins/observability.md +++ b/docs/plugins/observability.md @@ -10,18 +10,8 @@ Backstage integrator. ## Google Analytics -There is a basic Google Analytics integration built into Backstage. You can -enable it by adding the following to your app configuration: - -```yaml -app: - googleAnalyticsTrackingId: UA-000000-0 -``` - -Replace the tracking ID with your own. - -For more information, learn about Google Analytics -[here](https://marketingplatform.google.com/about/analytics/). +See how to install Google Analytics in your app +[here](../integrations/google-analytics/installation.md) ## Logging diff --git a/microsite/sidebars.json b/microsite/sidebars.json index 0b3c8f5915..799433b8ef 100644 --- a/microsite/sidebars.json +++ b/microsite/sidebars.json @@ -112,6 +112,11 @@ "type": "subcategory", "label": "LDAP", "ids": ["integrations/ldap/org"] + }, + { + "type": "subcategory", + "label": "Google Analytics", + "ids": ["integrations/google-analytics/installation"] } ], "Plugins": [ diff --git a/mkdocs.yml b/mkdocs.yml index 00824392a7..6b1971ce03 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -70,6 +70,8 @@ nav: - Org Data: 'integrations/github/org.md' - LDAP: - Org Data: 'integrations/ldap/org.md' + - Google Analytics: + - Installation: 'integrations/google-analytics/installation.md' - Plugins: - Overview: 'plugins/index.md' - Existing plugins: 'plugins/existing-plugins.md' diff --git a/packages/create-app/templates/default-app/packages/app/public/index.html b/packages/create-app/templates/default-app/packages/app/public/index.html index ea9208ca57..5653173480 100644 --- a/packages/create-app/templates/default-app/packages/app/public/index.html +++ b/packages/create-app/templates/default-app/packages/app/public/index.html @@ -48,6 +48,22 @@ } <%= app.title %> + <% if (app.googleAnalyticsTrackingId && typeof app.googleAnalyticsTrackingId + === 'string') { %> + + + <% } %>