Profile Filter Links: list

Requires authorization

Lists all profile filter links for a profile. Try it now or see an example.

Request

HTTP request

GET https://www.googleapis.com/analytics/v3/management/accounts/accountId/webproperties/webPropertyId/profiles/profileId/profileFilterLinks

Parameters

Parameter name Value Description
Path parameters
accountId string Account ID to retrieve profile filter links for.
profileId string Profile ID to retrieve filter links for. Can either be a specific profile ID or '~all', which refers to all the profiles that user has access to.
webPropertyId string Web property Id for profile filter links for. Can either be a specific web property ID or '~all', which refers to all the web properties that user has access to.
Optional query parameters
max-results integer The maximum number of profile filter links to include in this response.
start-index integer An index of the first entity to retrieve. Use this parameter as a pagination mechanism along with the max-results parameter.

Authorization

This request requires authorization with at least one of the following scopes (read more about authentication and authorization).

Scope
https://www.googleapis.com/auth/analytics.edit
https://www.googleapis.com/auth/analytics.readonly

Request body

Do not supply a request body with this method.

Response

If successful, this method returns a response body with the following structure:

{
  "kind": "analytics#profileFilterLinks",
  "username": string,
  "totalResults": integer,
  "startIndex": integer,
  "itemsPerPage": integer,
  "previousLink": string,
  "nextLink": string,
  "items": [
    management.profileFilterLinks Resource
  ]
}
Property name Value Description Notes
kind string Collection type.
username string Email ID of the authenticated user
totalResults integer The total number of results for the query, regardless of the number of results in the response.
startIndex integer The starting index of the resources, which is 1 by default or otherwise specified by the start-index query parameter.
itemsPerPage integer The maximum number of resources the response can contain, regardless of the actual number of resources returned. Its value ranges from 1 to 1,000 with a value of 1000 by default, or otherwise specified by the max-results query parameter.
items[] list A list of profile filter links.

Examples

Note: The code examples available for this method do not represent all supported programming languages (see the client libraries page for a list of supported languages).

Java

Uses the Java client library.

/*
 * Note: This code assumes you have an authorized Analytics service object.
 * See the Filters Developer Guide for details.
 */

/*
 * Example #1:
 * Requests a list of all profile filter links for the authorized user.
 */
try {
  ProfileFilterLinks filterLinks = analytics.management().
      profileFilterLinks().list("123456", "UA-123456-1",
          "7654321").execute();

} catch (GoogleJsonResponseException e) {
  System.err.println("There was a service error: "
      + e.getDetails().getCode() + " : "
      + e.getDetails().getMessage());
}

/*
 * Example 2:
 * The results of the list method are stored in the filterLinks object.
 * The following code shows how to iterate through them.
 */
for (ProfileFilterLink link : filterLinks.getItems()) {
  System.out.println("Link Id = " + link.getId());
  System.out.println("Link Kind = " + link.getKind());

  // Get the profile reference.
  ProfileRef profileRef = link.getProfileRef();
  System.out.println("Profile Id = " + profileRef.getId());
  System.out.println("Profile Kind = " + profileRef.getKind());
  System.out.println("Profile Account Id = " + profileRef.getAccountId());
  System.out.println("Profile Property Id = " + profileRef.getWebPropertyId());
  System.out.println("Profile Name = " + profileRef.getName());

  // Get the filter reference.
  FilterRef filterRef = link.getFilterRef();
  System.out.println("Filter Id = " + filterRef.getId());
  System.out.println("Filter Account Id = " + filterRef.getAccountId());
  System.out.println("Filter Name = " + filterRef.getName());
}

Python

Uses the Python client library.

# Note: This code assumes you have an authorized Analytics service object.
# See the Filters Developer Guide for details.

# Example #1:
# Requests a list of all profile filter links for the authorized user.
try:
  filterLinks = analytics.management().profileFilterLinks().list(
      accountId='123456'
      webPropertyId='UA-123456-1',
      profileId='7654321'
  ).execute()

except TypeError, error:
  # Handle errors in constructing a query.
  print 'There was an error in constructing your query : %s' % error

except HttpError, error:
  # Handle API errors.
  print ('There was an API error : %s : %s' %
         (error.resp.status, error.resp.reason))


# Example #2:
# The results of the list method are stored in the filterLinks object.
# The following code shows how to iterate through them.
for link in filterLinks.get('items', []):
  print 'Link Id = %s' % link.get('id')
  print 'Link Kind = %s' % link.get('kind')

  # Get the profile reference.
  profileRef = link.get('profileRef', {})
  print 'Profile Id = %s' % profileRef.get('id')
  print 'Profile Kind = %s' % profileRef.get('kind')
  print 'Profile Account Id = %s' % profileRef.get('accountId')
  print 'Profile Property Id = %s' % profileRef.get('webPropertyId')
  print 'Profile Name = %s' % profile.get('name')

  # Get the filter reference.
  filterRef = link.get('filterRef', {})
  print 'Filter Id = %s' % filterRef.get('id')
  print 'Filter Account Id = %s' % filterRef.get('accountId')
  print 'Filter Name = %s' % filterRef.get('name')

Try it!

Use the APIs Explorer below to call this method on live data and see the response. Alternatively, try the standalone Explorer.