google/analytics
Use this extension when your website or web app sends events to Google Analytics from the browser.
In a Condition, you list the kinds of events that your site sends, such as page views. You also give the environment variable that holds the Google Analytics measurement ID, the ID that starts with G-. The platform then sets up a Google Analytics property and puts its measurement ID in that variable.
Documentation
This experimental extension defines the requirement made by a web workload that
sends analytics events to Google Analytics. It intentionally does not place a
Google Analytics measurement ID in a Profile. The Profile declares the logical
measurementId configuration property and the environment-variable name from
which the target environment supplies its value.
The first immutable candidate release is
0.1.0.
Example Condition:
- name: site-analytics
kind: google.analytics
interface:
type: web
events:
- page_view
configuration:
env:
- property: measurementId
name: GA_MEASUREMENT_ID
Packages
Install the package for your language to declare this extension's Conditions from your code.
Go
This package version is generated but not published to its registry yet.
go get runtimeconditions.io/x/google/analytics@v0.2.0
Conditions
Every Condition part this package defines, with the fields you can set. Select a line to open it.
google.analytics · web: Events sent from a web page in the browser.
analytics.Web is the interface of a google.analytics Condition.
| Field | Type | Required | Description |
|---|---|---|---|
Events |
Events |
yes | The kinds of events that your site sends to Google Analytics. List at least one. page_view, custom_event or both, each one once. Values: custom_event: Events that your site defines itself, such as sign_up or add_to_cart.page_view: A page view, sent each time someone opens a page. |
configuration on google.analytics · web: How your workload gets the Google Analytics measurement ID.
analytics.Configuration sets the configuration field of a google.analytics Condition.
| Field | Type | Required | Description |
|---|---|---|---|
Env |
Env |
yes | The environment variables for Google Analytics. One of them must hold the measurementId. |
GoogleAnalytics
analytics.GoogleAnalytics declares a google.analytics Condition.
Example: a website that records each page view, and reads its measurement ID from GA_MEASUREMENT_ID.
analytics.GoogleAnalytics(
analytics.Web{
Events: analytics.Events{
analytics.EventsItemPageView,
},
},
analytics.Configuration{
Env: analytics.Env{
map[string]any{"name": "GA_MEASUREMENT_ID", "property": "measurementId"},
},
},
)
Configuration
analytics.Configuration sets the configuration field of google.analytics Conditions with interface type web.
How your workload gets the Google Analytics measurement ID. List the environment variable that holds it, with property set to measurementId.
The full API, with every type, field and constant documented, is in the Go package documentation.
Python
This package version is generated but not published to its registry yet.
pip install runtimeconditions-google-analytics
Conditions
Every Condition part this package defines, with the fields you can set. Select a line to open it.
google.analytics · web: Events sent from a web page in the browser.
Web is the interface of a google.analytics Condition.
| Field | Type | Required | Description |
|---|---|---|---|
events |
Events |
yes | The kinds of events that your site sends to Google Analytics. List at least one. page_view, custom_event or both, each one once. Values: custom_event: Events that your site defines itself, such as sign_up or add_to_cart.page_view: A page view, sent each time someone opens a page. |
configuration on google.analytics · web: How your workload gets the Google Analytics measurement ID.
Configuration sets the configuration field of a google.analytics Condition.
| Field | Type | Required | Description |
|---|---|---|---|
env |
Env |
yes | The environment variables for Google Analytics. One of them must hold the measurementId. |
google_analytics
google_analytics declares a google.analytics Condition.
Example: a website that records each page view, and reads its measurement ID from GA_MEASUREMENT_ID.
from runtimeconditions_google_analytics import (
Configuration,
EventsItem,
Web,
google_analytics,
)
google_analytics(
Web(events=[EventsItem.PAGE_VIEW]),
Configuration(env=[{"property": "measurementId", "name": "GA_MEASUREMENT_ID"}]),
)
Configuration
Configuration sets the configuration field of google.analytics Conditions with interface type web.
How your workload gets the Google Analytics measurement ID. List the environment variable that holds it, with property set to measurementId.
Every class, field and enum member is documented in the package's docstrings.
TypeScript
This package version is generated but not published to its registry yet.
npm install @runtimeconditions/google-analytics
Conditions
Every Condition part this package defines, with the fields you can set. Select a line to open it.
google.analytics · web: Events sent from a web page in the browser.
Web is the interface of a google.analytics Condition.
| Field | Type | Required | Description |
|---|---|---|---|
events |
Events |
yes | The kinds of events that your site sends to Google Analytics. List at least one. page_view, custom_event or both, each one once. Values: custom_event: Events that your site defines itself, such as sign_up or add_to_cart.page_view: A page view, sent each time someone opens a page. |
configuration on google.analytics · web: How your workload gets the Google Analytics measurement ID.
Configuration sets the configuration field of a google.analytics Condition.
| Field | Type | Required | Description |
|---|---|---|---|
env |
Env |
yes | The environment variables for Google Analytics. One of them must hold the measurementId. |
googleAnalytics
googleAnalytics declares a google.analytics Condition.
Example: a website that records each page view, and reads its measurement ID from GA_MEASUREMENT_ID.
import { Configuration, EventsItem, Web, googleAnalytics } from "@runtimeconditions/google-analytics";
googleAnalytics(
new Web({ events: [EventsItem.PageView] }),
new Configuration({ env: [{ property: "measurementId", name: "GA_MEASUREMENT_ID" }] }),
);
Configuration
Configuration sets the configuration field of google.analytics Conditions with interface type web.
How your workload gets the Google Analytics measurement ID. List the environment variable that holds it, with property set to measurementId.
Every class, field and enum member is documented in the package's type declarations.
Java
This package version is generated but not published to its registry yet.
<dependency>
<groupId>io.runtimeconditions.bindings</groupId>
<artifactId>runtimeconditions-google-analytics</artifactId>
<version>0.2.0</version>
</dependency>
Conditions
Every Condition part this package defines, with the fields you can set. Select a line to open it.
google.analytics · web: Events sent from a web page in the browser.
Web is the interface of a google.analytics Condition.
| Field | Type | Required | Description |
|---|---|---|---|
events |
Events |
yes | The kinds of events that your site sends to Google Analytics. List at least one. page_view, custom_event or both, each one once. Values: custom_event: Events that your site defines itself, such as sign_up or add_to_cart.page_view: A page view, sent each time someone opens a page. |
configuration on google.analytics · web: How your workload gets the Google Analytics measurement ID.
Configuration sets the configuration field of a google.analytics Condition.
| Field | Type | Required | Description |
|---|---|---|---|
env |
Env |
yes | The environment variables for Google Analytics. One of them must hold the measurementId. |
Bindings.googleAnalytics
Bindings.googleAnalytics declares a google.analytics Condition.
Example: a website that records each page view, and reads its measurement ID from GA_MEASUREMENT_ID.
import io.runtimeconditions.bindings.googleanalytics.Bindings;
import io.runtimeconditions.bindings.googleanalytics.Configuration;
import io.runtimeconditions.bindings.googleanalytics.Env;
import io.runtimeconditions.bindings.googleanalytics.Events;
import io.runtimeconditions.bindings.googleanalytics.EventsItem;
import io.runtimeconditions.bindings.googleanalytics.Web;
import java.util.List;
import java.util.Map;
Bindings.googleAnalytics(
new Web(new Events(List.of(EventsItem.PAGE_VIEW))),
new Configuration(
new Env(List.of(Map.of("name", "GA_MEASUREMENT_ID", "property", "measurementId")))));
Configuration
Configuration sets the configuration field of google.analytics Conditions with interface type web.
How your workload gets the Google Analytics measurement ID. List the environment variable that holds it, with property set to measurementId.
Every record, component and enum constant is documented in the Javadoc.
Kinds
google.analytics
Your workload sends events to Google Analytics.
Example: a website that records each page view, and reads its measurement ID from GA_MEASUREMENT_ID.
kind: google.analytics
interface:
type: web
events: [page_view]
configuration:
env:
- property: measurementId
name: GA_MEASUREMENT_ID
Interface types
Interface types
web
Events sent from a web page in the browser.
Example: a web shop that records page views and its own events, such as add_to_cart. It reads its measurement ID from NEXT_PUBLIC_GA_ID.
kind: google.analytics
interface:
type: web
events: [page_view, custom_event]
configuration:
env:
- property: measurementId
name: NEXT_PUBLIC_GA_ID
Fields
interface.eventsThe kinds of events that your site sends to Google Analytics. List at least one.
| Value | Description |
|---|---|
page_view | A page view, sent each time someone opens a page. |
custom_event | Events that your site defines itself, such as sign_up or add_to_cart. |
Condition fields
configurationHow your workload gets the Google Analytics measurement ID. List the environment variable that holds it, with property set to measurementId.
| Value | Description |
|---|---|
measurementId | The variable holds the Google Analytics measurement ID, such as G-ABC123XYZ. |