Skip to main content
Glama
googleanalytics

Google Analytics MCP Server

Official

list_google_ads_links

Retrieve linked Google Ads accounts for a Google Analytics property by providing the property ID.

Instructions

Returns a list of links to Google Ads accounts for a property.

Args:
    property_id: The Google Analytics property ID. Accepted formats are:
      - A number
      - A string consisting of 'properties/' followed by a number

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
property_idYes

Implementation Reference

  • The main handler function for the 'list_google_ads_links' MCP tool. It is decorated with @mcp.tool() for registration and implements the logic to fetch Google Ads links for a specified property using the Google Analytics Admin API v1beta.
    @mcp.tool(title="List links to Google Ads accounts")
    async def list_google_ads_links(property_id: int | str) -> List[Dict[str, Any]]:
        """Returns a list of links to Google Ads accounts for a property.
    
        Args:
            property_id: The Google Analytics property ID. Accepted formats are:
              - A number
              - A string consisting of 'properties/' followed by a number
        """
        request = admin_v1beta.ListGoogleAdsLinksRequest(
            parent=construct_property_rn(property_id)
        )
        # Uses an async list comprehension so the pager returned by
        # list_google_ads_links retrieves all pages.
        links_pager = await create_admin_api_client().list_google_ads_links(
            request=request
        )
        all_pages = [proto_to_dict(link_page) async for link_page in links_pager]
        return all_pages

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/googleanalytics/google-analytics-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server