BETA: Working with dynamic data sources

A dynamic data source is a data source which uses one or more variables in its query instead of hard-coded values, thereby enabling the ability to dynamically retrieve data. Dynamic data sources offer a solution for users who need more flexibility in working with large amounts of data or data that requires multiple instances. 

Here are some important things to know when working with dynamic data sources:

  • Dynamic data sources are typically used for pagination, combining data sources, dynamic dashboards, and date queries.
  • Dynamic data sources should NOT be used to implement security. They are variable driven and variable values can be accessed through different features, for example, permalinks, where all the variables and values are included in the URL. If you want to implement security to prevent users from accessing your data, create a specific data source with the parameters and values set in the data source definition, without using variables.
  • You cannot reconfigure or duplicate an existing non-dynamic data source. Dynamic data sources must be created from scratch.

This article uses a Google Analytics data source as an example for how to work with dynamic data sources.

Step 1: Creating a variable with a value

In the Klip Editor, create a variable for the dynamic data source to use. 

  1. Click Klips in the left navigation bar.
  2. Click Build a Custom Klip.
  3. Drag the Value Pair component into the Klip Editor workspace.
  4. Click the Advanced Tools button and select Create New Variable... from the drop-down list.
  5. Type a Variable Name and a Value. For example, gaID and 1234567.
  6. Click Create Variable.
  7. Repeat for any additional variables you want to set up. It is not necessary to save the Klip

Note: The variable used in a dynamic data source must be set to a value that will return valid results when used in the data source query.

Step 2: Setting up the data source URL

Set up the variable in a data source URL.

  1. Click Data Sources in the left navigation bar.
  2. Click Create a New Data Source, select the Google Analytics option and authenticate with Google Analytics.
  3. From the New Data Source page, perform the following tasks.
    1. Create your Google Analytics query.
    2. Switch to Advanced mode.
    3. In the Query URI, type the variable in place of a hard-coded value, using the format {props.gaID}. 

For example, in

https://www.googleapis.com/analytics/v3/data/ga?ids=ga:1234567&start-date=date.startOfYear&end-date={date.today}

replace 1234567 with {props.gaID} where the gaID variable is assigned a value that will return valid results when used in the data source query

https://www.googleapis.com/analytics/v3/data/ga?ids=ga:{props.gaID}&start-date=date.startOfYear&end-date={date.today}

  1. Click Submit, then click Continue.
  2. Name and Save the data source.

Using the dynamic data source in a Klip

A user input control component and a table component demonstrate how to use a Google Analytics dynamic data source in a Klip.

Build a User Input Control component:

  1. Click Klips in the left navigation bar.
  2. Click Build a Custom Klip.
  3. Drag the User Input Control component into the Klip Editor workspace.
  4. Select the Properties tab.
  5. Select the Values subcomponent and create an ARRAY with a list of Google Analytic IDs
    1. Type a Control Label.
    2. Set Control Type to Drop-Down List.
    3. Set Value to the variable you created earlier. For example, gaID.
  6. Select the Values subcomponent and either create an ARRAY with a list of Google Analytic IDs or select a list of Google Analytic IDs from a data source (typically a spreadsheet).

Build a Table component:

  1. Click Klips in the left navigation bar.
  2. Click Build a Custom Klip.
  3. Drag the Table component into the Klip Editor workspace.
  4. Click +Add Data Source and select your dynamic data source from the list.
  5. In the Klip Editor:
  • For Column 1 select the variable, gaID. Format as Text.
  • For Column 2 select Column B (ga:visitors) from the dynamic data source and wrap with the SLICE function to remove the row header, Format as Number.
  • Name the Columns and Save the Klip.

When a Google Analytic ID is selected from the User Input Control, a dynamic data source instance is created and the table automatically responds to display the data for the Google Analytic ID selected.

Learn more:

Now that you know more about dynamic data sources, check out the following: