Creating A Custom Dynamic Segment

One of the features of the Google Analytics connector is the ability to create a custom dynamic segment, which is really useful when you are sharing workbooks with others. Custom segments in Google Analytics are stored as personal assets — they are associated with the login account, not the Google Analytics account. Because of that, using one of your custom segments in a query means other people cannot run your query; they will get an error when they try to refresh the query. 

By using a dynamic query, you build the segment definition into the query itself, and it can be run by anyone. The connector provides a blank space for entering any segment definition you want, but that means you need to build one that the API can understand. While that sounds daunting, you can use Google Analytics to help you with that step.

First, go into Google Analytics and create a new custom segment with a simple (temporary) name. I tend to use ‘[a]’ because it forces it to appear at the top of the list.

Then edit your query in Analytics Edge, and go to the Segments tab. Select the custom segment in the list and you will see the API definition on the right. Highlight the definition (starting at the end seems to be easier) and right-mouse-click to Copy from the pop-up menu.

Then scroll back to the top and select Dynamic Segment, and click the Edit button.

Select the bottom tab (Custom) and Paste the definition into the space provided. Click Finish to save the segment definition into your query.