Google Analytics MCP Setup Tutorial

Google Analytics MCP Setup Tutorial

Machine-readable: Markdown · JSON API · Site index

Поделиться Telegram VK Бот
Транскрипт Скачать .md
Анализ с AI

Оглавление (2 сегментов)

Segment 1 (00:00 - 05:00)

Hello and welcome. I'm Matt Landers, head of developer relations for Google Analytics. And in this video, we're going to walk through how to set up the new Analytics MCP server. So, what we're going to do is we're going to walk through the steps that are outlined on the readme on the GitHub repo so that you can see how to hook analytics data up to the LLM of your choice. In this video, we're going to use the Gemini CLI in order to talk to our analytics data. All right, let's get started. The first thing we want to do is find the setup instructions for the MCP server, which can be found on our GitHub page. So, if you go to our GitHub, you can scroll down and you'll find setup instructions. And then we're going to walk through those and see what it is that we need to do. The very first thing we need to do is make sure that we have Python running on our computer. I'm not going to walk through how to install Python. This is different for every OS version and there's plenty of documentation on how to make this work and other videos for that. But what I do want you to look at is the minimum version of Python required by the server. So if we go to the piprototl file, we can find this requires Python version. And right now it's 3. 10. That may be different by the time you watch this video. So just go here and check and make sure you're on the right version. The way that we can know that we're on the right version is to go over to our terminal. So, let me switch over to that. And then all we have to do is run python- version. And this will show us the version that we're running. Right now, I'm running 3. 11. 2. Uh, you just want to make sure that your version is greater than whatever the minimum version is. Once we validate the version is correct, we can now go on to the next step, which is to configure pipex. Pipex is a way for us to run Python applications without having to actually pull them down and run them locally on our computer. It does all that for us. Now, what you want to do is just click on the link here for configure pipex and follow the instructions based on the OS that you have. Once you've done that, we can switch back over to our terminal to make sure that it's actually working. So, let's do that. We're going to pull up our terminal and we're just going to type pipex run calc. This is a fun one. minus t and just say moo. And if everything is running, you should see a little cow with some text that says whatever is behind the dash t, which we said moo. So now we know pipex is running and we can move on to the next step. Now that we've validated our runtime environment is set up and working correctly, we can move on to a couple things that we need to do for Google Analytics in order to call the APIs. We want to be able to call the admin and data API. And in order to do that, we need to have a Google Cloud project. So you'll want to log in to the Google Cloud console and then it should look something like this. You may need to create a new project. Go ahead and do that. And now what we're going to do is we're going to enable those APIs for this project. So we're going to go to our search box and we're going to search for API and we'll go to APIs and services. We'll go to library and then we just want to search for analytics. Here we're going to want to enable the admin API and the data API. So let's go ahead and click on the admin API and we'll click enable. Once that's enabled, we can go back and enable the data API. All right, we've now enabled those two APIs. The next thing we need to do is authentication. All right, the first thing that we need to do for authentication is to get an OOTH client. And I know that sounds scary maybe if you don't know what that is, but I'll walk you through all the steps. So, go here and search for O. We're going to go to the Google O platform. When you get here, you may have to enter some contact information and a name for your project. But we're going once you do that, you can go to clients and we're going to create a new client. First, we want to choose the application type. We're going to be running this locally on our computer. So, we want to choose desktop app. Next, we want to name the client. I'm going to call it my analytics MCP OOTH client. All right. And then I'm going to just say create. Once I'm done that, it's going to create the client for me. And I need to download this JSON file that we're going to use for the next step, which is to finally do the authentication with G-Cloud. So, click download and make sure you save this somewhere where you know where it is. All right. Now that we have our OOTH client file, we can use the G-Cloud CLI to set up our application default credentials, which is how the MCP server authenticates with

Segment 2 (05:00 - 08:00)

the admin and data API. In order to do that, we need to install the G-Cloud CLI. So, you're going to go to this install page and choose the instructions for your operating system. Now, you can find a link to this in the description of this video, or you can search for install G-Cloud CLI. Once you have that installed, we can go ahead and run the command to authenticate with Google. Now that we have G-Cloud installed, we can go ahead and run a command that will allow us to authenticate with Google so that we can call our APIs. All right, so we're going to go into our setup instructions and we're just going to copy this first command here. We're not going to use the second command. We're JSON client file for OOTH instead of a service account. So, we're just going to copy this one and then we're going to paste that into our terminal. So, let's go ahead and do that. We'll paste that in. And the only thing that you need to change here is this last thing where it says your client JSON file and put the location of your file that you downloaded from your Google Cloud project, that ooth client file. It might have a weird file name. You can rename that to something simpler if you need to, but you got to put the full path to that file here. Once you do, you click enter. It'll pop up a screen for you to log in with your Google account. After you do that, it'll save another file, an application default credentials file that we'll use with the MCP server config. All right, on to the next step. All right, we're finally there. The moment we've been waiting for. We're going to configure Gemini CLI in order to use our MCP server. Now, you can use any LLM application that you want that supports MCP servers. We're going to use Gemini CLI here, but the configuration should be pretty much the same. You just need to check out what it is for whatever app you're using. So, before you do this, you're going to need to make sure you've installed Gemini CLI and you've got that up and working. And then we're just going to go edit the configuration file. So, we can go here. We can copy this config that we have for you on the setup instructions. And then we're going to go to a terminal and open that open the settings. json file for Gemini. Paste this in and update it with our information. So let's go ahead and go to our terminal. And I'm going to use Vim just so I can stay in here, but you can use whatever text editor that you want. All right, we'll go into our file and we're just going to copy in that configuration. We're also going to need to update these two environment variables, which is our path to our credentials. json, which is what we just created. We need to point it to that file. So, put the full path and file name here. And then your Google project ID. This is the project ID that's found on your Google Cloud Console. It's right there on the homepage. You can copy that and paste that in here. Once you get those two things in here, you can run the GM Gemini CLI and you'll be able to chat with your analytics data. All right, that's all the configuration there is in the setup. I know that it's a little bit complicated. We'd love to get your feedback. We want to improve this in the future, but for now, this is what it takes to get set up. Please leave any issues that you're having on the GitHub project or join our Discord server and join the analytics-m channel and you can ask us questions there, give us feedback and let us know what you want to see in the future. So until then, happy measuring.

Другие видео автора — Google Analytics

Ctrl+V

Экстракт Знаний в Telegram

Экстракты и дистилляты из лучших YouTube-каналов — сразу после публикации.

Подписаться

Дайджест Экстрактов

Лучшие методички за неделю — каждый понедельник