The Embed API provides developers several built-in components for querying and displaying report data. All components are built on a common base and thus share many of the same methods. This section provides an overview of how to use those shared methods. For more information about the individual components, see the component reference.
Component Options
Component options are set at creation time via the constructor function by invoking the set method on the instance. To get the state of a component instance at any point you may call get
and its current options will be returned.
Component Interaction
Components emit events when something important happens, allowing other components to respond when those events occur. To register a handler with a particular event, simply call the on
method. Alternatively, you may use the once
method, which is like on
but its handler will only be invoked the first time and then automatically removed. To remove a handler you may use the off
method.
Usually you'll just listen for the default events emitted by the components, but if you need to emit your own event, you can do so via the emit
method.
Analytics Client Library
The Embed API also loads the Google Analytics client library, which gives you access to many of the other Google Analytics APIs should you need them.
The following APIs are available at these namespaces:
gapi.client.analytics.data.ga gapi.client.analytics.data.mcf gapi.client.analytics.data.realtime gapi.client.analytics.management gapi.client.analytics.metadata