Analytics Reporter - Exemple complet
Créez un agent IA qui se connecte à Google Analytics, analyse le trafic de votre site web, génère des insights et envoie des rapports quotidiens automatisés à votre équipe.
Ce que vous allez construire
Un agent de reporting analytics qui :
- Se connecte à Google Analytics 4 (GA4)
- Interroge les métriques de trafic et le comportement des utilisateurs
- Identifie les tendances et les anomalies
- Génère des rapports quotidiens/hebdomadaires
- Crée des recommandations actionnables
- Envoie les rapports par Slack ou email
Temps nécessaire : 45-60 minutes
Prérequis
Avant de commencer, vous avez besoin de :
- Un compte TeamDay avec une organisation
- Une propriété Google Analytics 4 avec des données
- Un projet Google Cloud (pour OAuth)
- Une clé API Anthropic
- (Optionnel) Un workspace Slack pour les notifications
Vue d’ensemble de l’architecture
graph LR
A[Scheduled Mission] --> B[Analytics Agent]
B --> C[Google Analytics MCP]
C --> D[GA4 API]
B --> E[Data Analysis]
E --> F[Report Generation]
F --> G[Slack/Email]
B --> H[Insights Agent]
H --> I[Recommendations]
Étape 1 : Configuration Google Cloud
1.1 Créer un projet Google Cloud
- Rendez-vous sur Google Cloud Console
- Créez un nouveau projet : “TeamDay Analytics”
- Notez votre Project ID :
teamday-analytics-12345
1.2 Activer l’API Google Analytics
# Avec gcloud CLI
gcloud services enable analyticsdata.googleapis.com
gcloud services enable analytics.googleapis.com
# Ou via Cloud Console :
# APIs & Services → Enable APIs → Rechercher "Google Analytics Data API"
1.3 Créer des identifiants OAuth 2.0
Créer un client OAuth :
- APIs & Services → Credentials
- Create Credentials → OAuth client ID
- Type d’application : Web application
- Nom : “TeamDay Analytics Reporter”
- URIs de redirection autorisés :
https://app.teamday.app/auth/google/callbackhttp://localhost:3000/auth/google/callback(pour les tests)
- Cliquez sur Create
- Téléchargez les identifiants JSON
Sauvegardez ces valeurs :
{
"client_id": "123456789-abc.apps.googleusercontent.com",
"client_secret": "GOCSPX-abcdef123456",
"redirect_uris": ["https://app.teamday.app/auth/google/callback"]
}
1.4 Obtenir un Refresh Token
Vous avez besoin d’un refresh token pour accéder à GA sans autorisation manuelle :
# Installer la bibliothèque Google OAuth
npm install -g google-auth-library
# Créer un script d'authentification
cat > get-refresh-token.js << 'EOF'
const { OAuth2Client } = require('google-auth-library');
const readline = require('readline');
const client = new OAuth2Client(
'YOUR_CLIENT_ID',
'YOUR_CLIENT_SECRET',
'http://localhost:3000/auth/google/callback'
);
const SCOPES = [
'https://www.googleapis.com/auth/analytics.readonly',
'https://www.googleapis.com/auth/analytics'
];
const authUrl = client.generateAuthUrl({
access_type: 'offline',
scope: SCOPES,
});
console.log('Authorize this app by visiting:\n', authUrl);
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
});
rl.question('Enter the code from that page here: ', async (code) => {
rl.close();
try {
const { tokens } = await client.getToken(code);
console.log('\nRefresh Token:', tokens.refresh_token);
console.log('\nSave this token securely!');
} catch (error) {
console.error('Error getting token:', error);
}
});
EOF
# Exécuter le script
node get-refresh-token.js
Suivez les instructions :
- Visitez l’URL d’autorisation
- Accordez les permissions
- Copiez le code de l’URL de redirection
- Collez-le dans le terminal
- Sauvegardez le refresh token :
1//abc123def456...
1.5 Obtenir l’ID de propriété GA4
Trouvez votre ID de propriété GA4 :
- Rendez-vous sur Google Analytics
- Admin → Property Settings
- Copiez l’ID de propriété :
123456789
Ou trouvez-le dans l’URL :
https://analytics.google.com/analytics/web/#/p123456789/...
^^^^^^^^^^
Étape 2 : Configuration de l’organisation TeamDay
2.1 Ajouter les clés API
Stockez vos identifiants dans TeamDay :
teamday auth login
teamday secrets set ANTHROPIC_API_KEY "sk-ant-api03-..."
teamday secrets set GA_CLIENT_ID "123456789-abc.apps.googleusercontent.com"
teamday secrets set GA_CLIENT_SECRET "GOCSPX-abcdef123456"
teamday secrets set GA_REFRESH_TOKEN "1//abc123def456..."
teamday secrets set GA_PROPERTY_ID "123456789"
Ou via l’API :
curl -X POST https://us.teamday.ai/api/secrets/set \
-H "Authorization: Bearer $TEAMDAY_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"organizationId": "org_xxx",
"secrets": {
"GA_CLIENT_ID": "123456789-abc.apps.googleusercontent.com",
"GA_CLIENT_SECRET": "GOCSPX-abcdef123456",
"GA_REFRESH_TOKEN": "1//abc123def456...",
"GA_PROPERTY_ID": "123456789"
}
}'
2.2 Créer un Space
Créez un space pour le travail d’analytics :
teamday spaces create "Analytics Reports"
# Obtenir l'ID du space
teamday spaces list
# Output: cs_analytics123...
Étape 3 : Installer Google Analytics MCP
3.1 Configuration du serveur MCP
Le serveur MCP Google Analytics permet à votre agent d’interroger les données GA4 :
Configuration :
{
"mcpServers": {
"google-analytics": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-google-analytics"],
"env": {
"GA_CLIENT_ID": "${GA_CLIENT_ID}",
"GA_CLIENT_SECRET": "${GA_CLIENT_SECRET}",
"GA_REFRESH_TOKEN": "${GA_REFRESH_TOKEN}",
"GA_PROPERTY_ID": "${GA_PROPERTY_ID}"
}
}
}
}
3.2 Installation via l’interface
- Ouvrez votre space
- Settings → MCP Plugins
- Cliquez sur “Install Plugin”
- Recherchez “Google Analytics”
- Configuration auto-remplie depuis les secrets
- Cliquez sur “Install & Test”
3.3 Installation via l’API
curl -X POST https://us.teamday.ai/api/plugins/install \
-H "Authorization: Bearer $TEAMDAY_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"spaceId": "cs_analytics123",
"plugin": "google-analytics",
"config": {
"mcpServers": {
"google-analytics": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-google-analytics"],
"env": {
"GA_CLIENT_ID": "${GA_CLIENT_ID}",
"GA_CLIENT_SECRET": "${GA_CLIENT_SECRET}",
"GA_REFRESH_TOKEN": "${GA_REFRESH_TOKEN}",
"GA_PROPERTY_ID": "${GA_PROPERTY_ID}"
}
}
}
}
}'
3.4 Vérifier l’installation MCP
Testez la connexion :
Vous : Test the Google Analytics connection
Agent : Testing Google Analytics MCP...
✅ Authentication successful
✅ Connected to property: 123456789
✅ Available metrics: 45
✅ Date range: 2023-01-01 to 2024-12-09
Ready to query analytics data!
Étape 4 : Créer l’agent Analytics
4.1 Créer l’agent principal
curl -X POST https://us.teamday.ai/api/v1/agents \
-H "Authorization: Bearer $TEAMDAY_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "Analytics Reporter",
"model": "claude-sonnet-4-6",
"visibility": "organization",
"organizationId": "org_xxx"
}'
Sauvegardez l’ID de l’agent : ag_analytics456
4.2 Configuration du System Prompt
# Analytics Reporter System Prompt
You are an expert data analyst specializing in web analytics and user behavior.
## Your Responsibilities
1. **Data Collection**
- Query Google Analytics for relevant metrics
- Pull data for specified time periods
- Handle date ranges and comparisons
2. **Analysis**
- Identify trends and patterns
- Spot anomalies and significant changes
- Calculate growth rates and percentages
- Compare periods (week-over-week, month-over-month)
3. **Insights Generation**
- Explain what the data means
- Identify opportunities and concerns
- Provide context for changes
- Highlight actionable insights
4. **Report Creation**
- Structure reports clearly
- Use appropriate visualizations (describe them)
- Prioritize most important findings
- Include recommendations
## Key Metrics to Track
**Traffic Metrics:**
- Total users and sessions
- New vs returning users
- Pageviews and unique pageviews
- Bounce rate
- Average session duration
**Acquisition:**
- Traffic sources (organic, direct, referral, social)
- Top referring sites
- Campaign performance
- Search keywords (if available)
**Behavior:**
- Top pages by views
- Top landing pages
- Exit pages
- User flow patterns
**Conversions:**
- Goal completions
- Conversion rates
- E-commerce metrics (if applicable)
- Form submissions
**Technical:**
- Device breakdown (desktop, mobile, tablet)
- Browser and OS distribution
- Page load times
- Error rates
## Analysis Framework
For each metric:
1. Current value
2. Comparison to previous period
3. Trend direction (↑↓→)
4. Significance of change
5. Possible explanations
## Report Format
Structure reports as:
### 📊 Analytics Report - [Date Range]
**Summary**
High-level overview (2-3 sentences)
**Key Findings**
- Most important insights
- Significant changes
- Opportunities or concerns
**Traffic Overview**
- User metrics
- Session metrics
- Engagement metrics
**Acquisition Analysis**
- Traffic sources breakdown
- Top performers
- Changes from last period
**Content Performance**
- Top pages
- Engagement by content type
- User journey insights
**Recommendations**
- Actionable next steps
- Areas to investigate
- Optimization opportunities
Use emojis for visual clarity: 📈 (growth), 📉 (decline), ⚠️ (concern), ✨ (opportunity)
Be data-driven but explain insights in plain language.
4.3 Définir les permissions de l’agent
curl -X PATCH https://us.teamday.ai/api/v1/agents/ag_analytics456 \
-H "Authorization: Bearer $TEAMDAY_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"permissions": {
"readFiles": true,
"writeFiles": true,
"executeCode": false,
"commitToGit": false,
"accessSecrets": false
}
}'
Étape 5 : Créer un sous-agent Insights (optionnel)
5.1 Créer un sous-agent spécialisé
Pour une analyse plus approfondie, créez un agent d’insights :
curl -X POST https://us.teamday.ai/api/v1/agents \
-H "Authorization: Bearer $TEAMDAY_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "Insights Analyzer",
"systemPrompt": "You analyze analytics data for trends and insights...",
"model": "claude-sonnet-4-6",
"visibility": "organization",
"organizationId": "org_xxx",
"type": "subagent"
}'
5.2 Lier à l’agent principal
curl -X PATCH https://us.teamday.ai/api/v1/agents/ag_analytics456 \
-H "Authorization: Bearer $TEAMDAY_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"subAgents": ["ag_insights789"]
}'
Étape 6 : Exemples d’utilisation
6.1 Requête analytics de base
Vous : What were our top pages yesterday?
Agent : Querying Google Analytics for yesterday's data...
## Top Pages - December 8, 2024
1. **/blog/getting-started**
- 1,247 views
- Avg time: 3m 24s
- Bounce rate: 42%
2. **/docs/api-reference**
- 892 views
- Avg time: 5m 12s
- Bounce rate: 28%
3. **/pricing**
- 634 views
- Avg time: 2m 08s
- Bounce rate: 55%
4. **/features**
- 521 views
- Avg time: 1m 45s
- Bounce rate: 62%
5. **/** (Homepage)
- 489 views
- Avg time: 1m 22s
- Bounce rate: 48%
**Insights:**
- Getting started guide remains top content
- API docs show high engagement (5+ min sessions)
- Pricing page has high bounce rate - consider optimization
6.2 Comparaison de trafic
Vous : Compare this week's traffic to last week
Agent : Analyzing week-over-week traffic data...
## Weekly Traffic Comparison
**This Week (Dec 2-8)** vs **Last Week (Nov 25-Dec 1)**
### Overall Traffic
- **Total Users:** 12,453 ↑ (+18.2%)
- Previous: 10,536
- Change: +1,917 users
- **Sessions:** 15,892 ↑ (+16.7%)
- Previous: 13,618
- Change: +2,274 sessions
- **Pageviews:** 42,156 ↑ (+22.3%)
- Previous: 34,478
- Change: +7,678 views
### Engagement Metrics
- **Avg Session Duration:** 3m 42s ↑ (+8.3%)
- Previous: 3m 25s
- Improvement in engagement
- **Bounce Rate:** 45.2% ↓ (-3.1%)
- Previous: 48.3%
- Good improvement
- **Pages/Session:** 2.65 ↑ (+11.8%)
- Previous: 2.37
- Users exploring more
### Traffic Sources
1. **Organic Search:** 6,234 users ↑ (+28.4%)
2. **Direct:** 3,892 users ↑ (+12.1%)
3. **Referral:** 1,456 users ↑ (+5.3%)
4. **Social:** 871 users ↑ (+45.2%) 📈
**Key Findings:**
✨ Strong growth across all metrics
✨ Social traffic spike - recent campaign working well
✨ Improved engagement indicates better content resonance
⚠️ Monitor capacity - ensure site performance scales
6.3 Générer un rapport quotidien complet
Vous : Generate today's daily analytics report
Agent : Creating comprehensive analytics report for December 9, 2024...
---
# 📊 Daily Analytics Report
**December 9, 2024**
## Executive Summary
Strong performance today with 1,834 users (+12% vs yesterday). Organic traffic continues to grow, and engagement metrics are healthy. Notable spike in mobile traffic suggests mobile optimization efforts are paying off.
## 🎯 Key Highlights
✨ **New users increased 22%** - acquisition efforts working
📈 **Mobile traffic up 34%** - mobile-first strategy succeeding
⚠️ **Bounce rate on /pricing increased to 61%** - needs attention
✨ **Blog engagement up 18%** - content strategy effective
## 📈 Traffic Overview
### Total Traffic
- **Users:** 1,834 (↑12% vs yesterday)
- **New Users:** 1,245 (↑22% vs yesterday)
- **Sessions:** 2,367 (↑15% vs yesterday)
- **Pageviews:** 6,892 (↑18% vs yesterday)
### Engagement
- **Avg Session Duration:** 3m 48s (↑5%)
- **Pages/Session:** 2.91 (↑8%)
- **Bounce Rate:** 43.2% (↓2.1%)
## 🚀 Acquisition Breakdown
| Source | Users | % of Total | Change |
|--------|-------|------------|--------|
| Organic Search | 892 | 48.6% | ↑15% |
| Direct | 567 | 30.9% | ↑8% |
| Referral | 234 | 12.8% | ↑23% |
| Social | 98 | 5.3% | ↑45% |
| Email | 43 | 2.3% | ↑12% |
**Top Referrers:**
1. news.ycombinator.com - 89 users
2. reddit.com/r/webdev - 56 users
3. dev.to - 34 users
## 📱 Device & Technology
### Device Category
- **Desktop:** 1,102 users (60.1%)
- **Mobile:** 652 users (35.5%) ↑34%
- **Tablet:** 80 users (4.4%)
### Browser
- Chrome: 62.3%
- Safari: 24.1%
- Firefox: 8.9%
- Edge: 3.2%
- Other: 1.5%
## 📄 Content Performance
### Top Pages
1. **/blog/api-best-practices** - 423 views
- 4m 32s avg time
- 32% bounce rate
- 📈 Trending up
2. **/docs/getting-started** - 389 views
- 5m 12s avg time
- 28% bounce rate
- → Steady
3. **/pricing** - 267 views
- 1m 45s avg time
- 61% bounce rate
- ⚠️ High bounce rate
4. **/features/automation** - 198 views
- 3m 21s avg time
- 38% bounce rate
5. **/** (Homepage) - 187 views
- 1m 33s avg time
- 45% bounce rate
### Top Landing Pages
1. /blog/api-best-practices (327 sessions)
2. / (198 sessions)
3. /docs/getting-started (156 sessions)
## 🎯 User Behavior Insights
### User Flow Analysis
**Most Common Path:**
Homepage → Features → Pricing → Sign Up
- Conversion rate: 8.2%
**High Exit Pages:**
1. /pricing (23% exit rate)
2. /contact (18% exit rate)
### Session Depth
- 1 page: 43.2%
- 2-3 pages: 34.1%
- 4-6 pages: 15.8%
- 7+ pages: 6.9%
## 💡 Recommendations
### High Priority
1. **Optimize /pricing page**
- Current bounce rate: 61%
- Add social proof or comparison table
- Consider A/B test on CTA placement
2. **Capitalize on HackerNews traffic**
- 89 referrals today
- Create follow-up content
- Engage in comments
### Medium Priority
1. **Mobile optimization working**
- 34% increase in mobile traffic
- Continue mobile-first approach
- Test mobile checkout flow
2. **Blog performing well**
- "API Best Practices" trending
- Create more technical content
- Add related article suggestions
### Monitoring
1. Watch organic growth trajectory
2. Track pricing page changes
3. Monitor mobile conversion rates
## 📊 Historical Context
**7-Day Trend:**
- Daily avg users: 1,654
- Today vs 7-day avg: ↑10.9%
- Consistent upward trend
**30-Day Comparison:**
- This week avg: 1,723 users/day
- Last 30 days avg: 1,498 users/day
- Growth: ↑15%
---
*Report generated by TeamDay Analytics Agent*
*Next report: December 10, 2024 at 9:00 AM UTC*
6.4 Demande d’analyse personnalisée
Vous : Analyze which traffic sources convert best
Agent : Analyzing conversion rates by traffic source...
## Conversion Analysis by Traffic Source
**Date Range:** Last 30 days
**Goal:** Sign-up conversion
### Conversion Rates by Source
| Source | Users | Conversions | Rate | AOV |
|--------|-------|-------------|------|-----|
| **Organic Search** | 15,234 | 892 | **5.9%** | $127 |
| **Email** | 1,245 | 156 | **12.5%** 📈 | $189 |
| **Referral** | 3,456 | 198 | **5.7%** | $145 |
| **Direct** | 8,923 | 445 | **5.0%** | $156 |
| **Social** | 2,134 | 67 | **3.1%** | $98 |
| **Paid Search** | 1,890 | 132 | **7.0%** | $134 |
### Key Insights
✨ **Email is your best converter** (12.5% rate)
- Highest rate and AOV
- Users are already engaged
- Recommendation: Increase email frequency, add nurture campaigns
📈 **Paid search over-performing organic** (7.0% vs 5.9%)
- Good keyword targeting
- Recommendation: Increase paid budget strategically
⚠️ **Social traffic underperforming** (3.1% rate)
- Low intent traffic
- Lowest AOV
- Recommendation: Better targeting, or focus on awareness vs conversion
### Revenue Impact
**Total Revenue (30 days):** $245,678
**By Source:**
1. Organic Search: $113,284 (46%)
2. Direct: $69,420 (28%)
3. Referral: $28,710 (12%)
4. Paid Search: $17,688 (7%)
5. Email: $29,484 (12%)
6. Social: $6,566 (3%)
**Recommendation:**
Despite lower conversion rate, organic drives most revenue due to volume. Focus on:
1. Maintaining organic rankings
2. Scaling email (best ROI)
3. Optimizing paid search (good performance)
4. Rethinking social strategy (low ROI)
Étape 7 : Automatisation et planification
7.1 Mission de rapport quotidien
Configurez des rapports quotidiens automatiques :
curl -X POST https://us.teamday.ai/api/missions \
-H "Authorization: Bearer $TEAMDAY_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "Daily Analytics Report",
"schedule": "0 9 * * *",
"agentId": "ag_analytics456",
"action": {
"type": "execute",
"prompt": "Generate today'\''s analytics report and post to #analytics Slack channel"
},
"organizationId": "org_xxx",
"spaceId": "cs_analytics123"
}'
7.2 Mission de résumé hebdomadaire
curl -X POST https://us.teamday.ai/api/missions \
-H "Authorization: Bearer $TEAMDAY_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "Weekly Analytics Summary",
"schedule": "0 9 * * 1",
"agentId": "ag_analytics456",
"action": {
"type": "execute",
"prompt": "Generate comprehensive weekly analytics report comparing to previous week, and email to [email protected]"
},
"organizationId": "org_xxx",
"spaceId": "cs_analytics123"
}'
Exemples de planification :
0 9 * * *- Tous les jours à 9h0 9 * * 1- Tous les lundis à 9h0 */4 * * *- Toutes les 4 heures0 9 1 * *- Le premier jour du mois à 9h
7.3 Mission de détection d’anomalies
Détectez les patterns de trafic inhabituels :
curl -X POST https://us.teamday.ai/api/missions \
-H "Authorization: Bearer $TEAMDAY_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "Anomaly Detection",
"schedule": "0 */6 * * *",
"agentId": "ag_analytics456",
"action": {
"type": "execute",
"prompt": "Check last 6 hours of traffic. Alert if traffic dropped >20% or spiked >50% compared to same time yesterday"
},
"organizationId": "org_xxx",
"spaceId": "cs_analytics123"
}'
Étape 8 : Intégration avec Slack (optionnel)
8.1 Installer Slack MCP
{
"mcpServers": {
"slack": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-slack"],
"env": {
"SLACK_BOT_TOKEN": "${SLACK_BOT_TOKEN}",
"SLACK_CHANNEL": "#analytics"
}
}
}
}
8.2 Envoyer un rapport à Slack
Vous : Send today's report to #analytics
Agent : Posting analytics report to Slack...
✅ Posted to #analytics
✅ Added chart visualizations
✅ Pinned message for visibility
View in Slack: https://yourworkspace.slack.com/...
Résultats attendus
Exemple de message Slack
📊 Daily Analytics Report - December 9, 2024
*Traffic Summary*
• Users: 1,834 (↑12%)
• Sessions: 2,367 (↑15%)
• Pageviews: 6,892 (↑18%)
*Key Highlights*
✨ New users up 22% - acquisition working
📈 Mobile traffic up 34% - optimization paying off
⚠️ Pricing bounce rate 61% - needs attention
*Top Pages Today*
1. /blog/api-best-practices (423 views)
2. /docs/getting-started (389 views)
3. /pricing (267 views)
*Recommendations*
• Optimize /pricing page (high bounce)
• Capitalize on HN traffic (89 referrals)
• Continue mobile-first approach
<View Full Report> | <Ask Follow-up>
Exemple de rapport par email
Subject: Daily Analytics Report - December 9, 2024
[Email HTML formaté avec graphiques et métriques]
Métriques clés, visualisations et insights
Lien vers le rapport complet dans TeamDay
Dépannage
Échec de l’authentification Google Analytics
Erreur :
Error: GA authentication failed (401 Unauthorized)
Solution :
- Vérifiez que le refresh token est valide
- Vérifiez que les identifiants OAuth sont corrects
- Assurez-vous que l’API GA4 est activée dans GCP
- Régénérez le refresh token s’il a expiré
- Vérifiez que l’ID de propriété est correct
Aucune donnée retournée
Erreur :
Error: No data available for date range
Solution :
- Vérifiez que la propriété contient des données pour les dates demandées
- Vérifiez que l’ID de propriété est correct
- Assurez-vous que l’utilisateur a accès en lecture à Analytics
- Essayez une plage de dates plus courte
- Vérifiez que la propriété est GA4 (pas Universal Analytics)
Le plugin MCP ne répond pas
Erreur :
Error: Google Analytics MCP timeout
Solution :
- Vérifiez la connectivité réseau
- Vérifiez que les APIs GCP sont activées
- Vérifiez les limites de taux (quota)
- Redémarrez le serveur MCP
- Consultez les logs du plugin
Écarts dans les données
Problème : Les chiffres ne correspondent pas à l’interface GA
Solution :
- Vérifiez que les plages de dates correspondent exactement
- Vérifiez les paramètres de fuseau horaire
- Tenez compte du délai de traitement des données (24-48h pour certaines métriques)
- Utilisez l’API realtime pour les données actuelles
- Vérifiez les filtres et segments
Configuration avancée
Configuration des métriques personnalisées
Définissez des métriques personnalisées à suivre :
{
"customMetrics": {
"signups": {
"eventName": "sign_up",
"type": "event"
},
"purchases": {
"eventName": "purchase",
"type": "event",
"parameters": ["value", "currency"]
},
"engagement": {
"eventName": "page_view",
"conditions": {
"session_duration": ">180"
}
}
}
}
Modèles de rapports
Créez des modèles de rapports réutilisables :
{
"templates": {
"executive_summary": {
"metrics": ["users", "sessions", "conversions"],
"dimensions": ["source", "medium"],
"dateRange": "last7days",
"comparison": "previousPeriod"
},
"content_performance": {
"metrics": ["pageviews", "avgSessionDuration", "bounceRate"],
"dimensions": ["pagePath", "pageTitle"],
"filters": {
"pagePath": "startsWith:/blog"
},
"orderBy": "pageviews desc",
"limit": 10
}
}
}
Seuils d’alerte
Configurez des alertes automatisées :
{
"alerts": {
"traffic_drop": {
"metric": "users",
"threshold": -20,
"period": "1hour",
"comparison": "same_time_yesterday",
"action": "slack_notification"
},
"conversion_spike": {
"metric": "conversions",
"threshold": 50,
"period": "1day",
"action": "email_team"
}
}
}
Estimation des coûts
API Google Analytics :
- Niveau gratuit : 25 000 requêtes/jour
- Rapport quotidien typique : ~10 requêtes
- Coût mensuel : $0 (dans le niveau gratuit)
Agent TeamDay :
- Rapport quotidien : ~8 000 tokens en entrée, ~3 000 en sortie
- Coût par rapport : ~$0.12
- Mensuel (30 jours) : ~$3.60
Coût total estimé : ~$4/mois
Prochaines étapes
Maintenant que vous avez un agent de reporting analytics, explorez :
- Exemple BigQuery Insights - Analysez les données historiques à grande échelle
- Code Review Bot - Corrélez les changements de code avec le trafic
- Serveurs MCP personnalisés - Créez des outils d’analytics personnalisés
- Guide d’automatisation - Planification et déclencheurs avancés