Skip to content

Conversation

@cagnusmarlsen
Copy link

This PR aims to add support for generating funnel reports using the Google Analytics MCP server. It adds a run_funnel_report tool that uses the runFunnelReport method to generate funnel reports based on user queries.

@google-cla
Copy link

google-cla bot commented Sep 2, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Copy link
Member

@jradcliff jradcliff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much for this PR! I added a few comments and suggestions.

  • Josh, Google Analytics team

Comment on lines 283 to 284
"""Run a Google Analytics Data API funnel report.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"""Run a Google Analytics Data API funnel report.
"""Run a Google Analytics Data API funnel report.
See the funnel report guide at
https://developers.google.com/analytics/devguides/reporting/data/v1/funnels
for details and examples.

"""


def _run_funnel_report_description() -> str:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you move this file into a funnel.py file, similar to how we separate out runReport into core.py, run_realtime_report into realtime.py, and get_custom_dimensions_and_metrics, etc. into metadata.py?

Comment on lines 296 to 314
Example:
[
{
"name": "Page View",
"filter_expression": {
"funnel_field_filter": {
"field_name": "eventName",
"string_filter": {
"match_type": "EXACT",
"value": "page_view"
}
}
}
},
{
"name": "Sign Up",
"event": "sign_up"
}
]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move the JSON examples into separate methods that you call here, similar to what we're doing with date range hints, etc. for runReport:

This offers a few advantages:

  1. It keeps this docstring reasonably short.
  2. In the methods that return JSON, you can use the client library to generate the JSON so you know that it's well-formed. This will also make maintenance easier if the API objects evolve and change.

@cagnusmarlsen
Copy link
Author

Hi Josh,
Thanks for reviewing! I apologize for the long delay, but I've made the requested changes. Thanks again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants