A strategic agent that ingests and synthesizes data from GA4, HubSpot lifecycle events, Google Search Console, and Google Ads to identify queries, pages, journeys, and messages driving qualified outcomes. It automatically converts validated insights into strategically defined HubSpot Marketing Events via the HubSpot Marketing Events API.
This agent acts as a control layer that:
- Ingests multi-source demand signals (GA4 behavior/conversions, HubSpot lifecycle events, Google Search Console demand signals, Google Ads performance)
- Synthesizes insights by identifying high-performing queries, pages, customer journeys, and messaging
- Creates strategic HubSpot Marketing Events that serve as the control layer for downstream social, content, and paid execution
- π Multi-Source Data Ingestion: Connects to GA4, HubSpot, Google Search Console, and Google Ads
- π§ Intelligent Synthesis: Weighted scoring algorithm identifies qualified insights
- π Automated Event Management: Creates, updates, and manages HubSpot Marketing Events via API
- βοΈ Configurable Scoring: Customize thresholds and weights for different signal types
- π― Actionable Recommendations: Generates specific recommendations for each insight
- π Sync Management: Automatically syncs insights with existing marketing events
npm installCopy .env.example to .env and configure your credentials:
cp .env.example .envHUBSPOT_API_KEY: Your HubSpot API key (Private App token recommended)HUBSPOT_PORTAL_ID: Your HubSpot portal/account ID
Configure only the data sources you want to use:
- GA4: Set
GA4_PROPERTY_IDandGA4_CREDENTIALS - Google Search Console: Set
GSC_SITE_URLandGSC_CREDENTIALS - Google Ads: Set
GOOGLE_ADS_CUSTOMER_IDandGOOGLE_ADS_CREDENTIALS
DAYS_BACK: Number of days to look back for data (default: 30)MIN_IMPRESSIONS: Minimum impressions threshold (default: 100)MIN_CONVERSIONS: Minimum conversions threshold (default: 1)MIN_SCORE: Minimum insight score threshold (default: 0.5)
Adjust the importance of different signals (must sum to 1.0):
WEIGHT_GA4: Weight for GA4 behavior data (default: 0.25)WEIGHT_LIFECYCLE: Weight for HubSpot lifecycle events (default: 0.35)WEIGHT_SEARCH: Weight for Search Console data (default: 0.20)WEIGHT_ADS: Weight for Google Ads data (default: 0.20)
npm run buildnpm startOr in development mode:
npm run devimport { MarketingEventsSynthesisAgent } from './agent';
import { loadIntegrationConfig, loadSynthesisConfig } from './config';
const integrationConfig = loadIntegrationConfig();
const synthesisConfig = loadSynthesisConfig();
const agent = new MarketingEventsSynthesisAgent(integrationConfig, synthesisConfig);
// Run complete synthesis and event creation
const result = await agent.run();
console.log(`Generated ${result.insights.length} insights`);
// Or just synthesize without creating events
const insights = await agent.synthesizeOnly();βββββββββββββββββββ
β Data Sources β
β - GA4 β
β - HubSpot β
β - Search Con. β
β - Google Ads β
ββββββββββ¬βββββββββ
β
βΌ
βββββββββββββββββββ
β Integrations β
β Layer β
ββββββββββ¬βββββββββ
β
βΌ
βββββββββββββββββββ
β Synthesis β
β Engine β
ββββββββββ¬βββββββββ
β
βΌ
βββββββββββββββββββ
β Qualified β
β Insights β
ββββββββββ¬βββββββββ
β
βΌ
βββββββββββββββββββ
β HubSpot β
β Marketing β
β Events API β
βββββββββββββββββββ
- Integrations Layer: Modules for each data source (GA4, HubSpot, Search Console, Google Ads)
- Synthesis Engine: Processes and scores insights based on configurable thresholds and weights
- Marketing Events API: Creates and manages HubSpot Marketing Events
- Agent Orchestrator: Coordinates the complete workflow
The agent generates four types of qualified insights:
- Query Insights: High-performing search queries from Search Console
- Page Insights: Pages driving significant engagement and conversions
- Journey Insights: Customer lifecycle transitions with high conversion rates
- Message Insights: Ad campaigns and messaging with strong performance
Insights are scored using a weighted formula:
Score = (GA4_weight Γ GA4_score) + (Lifecycle_weight Γ Lifecycle_score) +
(Search_weight Γ Search_score) + (Ads_weight Γ Ads_score)
Each signal is normalized and weighted according to your configuration. Only insights exceeding the minimum score threshold are converted to marketing events.
npm testnpm run lintnpm run lint:fixMain agent class that orchestrates the entire process.
run(): Execute complete synthesis and event creationsynthesizeOnly(): Generate insights without creating eventsgetCurrentEvents(): Retrieve existing marketing events
Core synthesis logic.
synthesizeInsights(data): Process multi-source data and generate qualified insights
HubSpot Marketing Events API client.
createEvent(insight): Create a new marketing eventupdateEvent(eventId, insight): Update an existing eventdeleteEvent(eventId): Delete an eventsyncEvents(insights): Sync insights with existing events
Contributions are welcome! Please follow these guidelines:
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Submit a pull request
ISC
For issues and questions, please open an issue in the GitHub repository.