How to Add a List of URLs to a Segment in Adobe Analytics

Gone are the days of manually copying and pasting a list of 50+ URLs into a segment in Adobe Analytics. There’s actually an easy way to import a list of URLs into a segment using the Adobe Analytics API via Swagger UI!

Swagger UI is an open-source interface that allows you to interact with APIs without having any of the implementation logic. Adobe has made it available for their Analytics API 2.0 so there’s no need for advanced coding skills.

This process requires the Adobe Analytics API so make sure you have an OAuth client that is subscribed to access the Adobe Analytics Reporting API.

By using the API, you’ll save time and focus on your analysis rather than focusing on data entry.

The step-by-step process

Now I’ll walk you through the steps of how to use the API. Let’s use a common example that comes up often in SEO: getting data for a long list of Entry Page URLs.

  1. Create a segment for the list of page URLs as you normally would in Adobe Analytics. Add at least two Entry Page URLs manually so you can select the comparative statement (ie: or, and, then) you want to use going forward.
Adobe Analytics Segment creator
  1. Log in to your account on Adobe’s Github API page here: https://adobedocs.github.io/analytics-2.0-apis/
  1. Once you’re logged in, go to the Segments dropdown, and then Get /segments. Click the Try it out button and scroll until you get to the expansion list. Select the additional metadata fields from this list. Then click the Execute button to get the JSON string, and make note of the Segment ID. This will give you the Segment ID to update the segment you just created with your list of URLs. 
  1. Now, you must retrieve the ID of the segment you want to update in the output from Step 2. The Segment ID is preceded by “id”: “. 

Under Get a Single Segment, select Try it out and input that Segment ID. Select all the additional metadata fields for the segment and then Execute.

  1. Using the values the output generated, replace the two values that are in brackets (but don’t delete the brackets!):
="{
        ""str"": """&A2&""",
        ""val"": {
          ""func"": ""attr"",                   
          ""name"": ""[variables/entrypage]""    
        },
        ""func"": ""streq"",
        ""description"": ""[Entry Page]""         
       },"

You will need to update the contents in the square brackets with whatever dimension you want to track. My dimension is “[entrypage]” in this example. 

Also, note that double quotes are needed to escape quotes if you’re using Excel or Google Sheets to create your list. The cell A2 is the URL or dimension, you want to update.

  1. Create a spreadsheet with Column A containing the URLs you want to track, and Column B having the formula we modified in the last step. For example:

Remember to remove the trailing comma in the last instance. The rest of the code that goes before and after the text you updated in Step 4 is generated by the Get a Single Segment from Step 3. 

  1. Under Update a Segment, click Try it out. Enter the Segment ID of the segment you want to modify. In the body, edit the value and delete the example text.

After you have one opening curly bracket, combine the JSON pieces together from Steps 3 and 4, then you are ready to Execute.

  1. It’s time to log in to Adobe Analytics and see your work. Go to your newly created segment and verify it’s updated with the full list of URLs.

Now you are ready to analyze your new segment in Adobe Analytics. Happy analyzing!

You can use this tool if you have a list of dimensions that you want to track, such as page names, categories, regions, etc.. All you need to modify is the code in Step 4. Keep in mind that the names in the dimension list must correspond to the ones in Adobe Analytics.

Full documentation of the Adobe Analytics 2.0 APIs is here for reference:

https://www.adobe.io/apis/experiencecloud/analytics/docs.html

If you have any further queries about this or any other questions about data analytics, please reach out to us at contact@ayima.com