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.

To demonstrate, these instructions use a Google Analytics data source as an example.

Note: You cannot reconfigure or duplicate an existing non-dynamic data source. Dynamic data sources must be created from scratch.

Step 1: Creating a variable with a value

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

  1. Go to Library and select the Klips tab.
  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. Go to Library and select the Data Sources tab.
  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 Get Data, 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. Go to Library and select the Klips tab.
  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. Go to Library and select the Klips tab.
    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:
      1. For Column 1 select the variable, gaID. Format as Text.
      2. 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.
      3. 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: