Skip to main content

Overview

The Blog Marketing Platform provides a powerful analytics system that tracks content performance, user engagement, and platform growth. Analytics are role-based, showing different data levels based on user permissions.

Analytics Dashboard

Overview Metrics

Total views, posts, active users, and engagement rates with growth trends

Traffic Analysis

Daily traffic patterns, user sessions, and visitor trends over time

Content Performance

Top-performing posts, category engagement, and author statistics

User Analytics

User activity, role distribution, and retention metrics

Analytics Data Structure

The platform provides comprehensive analytics organized into modules:
interface AnalyticsData {
  overview: AnalyticsOverview;         // High-level metrics
  trafficData: TrafficDataPoint[];     // Time-series traffic
  topPosts: TopPost[];                 // Best performers
  content: ContentAnalytics;           // Content insights
  users: UsersAnalytics;               // User metrics
  performance: PerformanceAnalytics;   // Technical metrics
}

Overview Metrics

High-level platform statistics with growth indicators:
interface AnalyticsOverview {
  totalViews: number;         // All-time page views
  totalPosts: number;         // Published posts count
  activeUsers: number;        // Active users this period
  engagementRate: number;     // Average engagement %
  viewsGrowth: number;        // Views change %
  postsGrowth: number;        // Posts change %
  usersGrowth: number;        // Users change %
  engagementGrowth: number;   // Engagement change %
}

Fetching Overview Data

import { getDashboardOverview } from '@/services/postsService';

const overview = await getDashboardOverview();
console.log(`Total posts: ${overview.totalPosts}`);
console.log(`Published: ${overview.published}`);
console.log(`Drafts: ${overview.draft}`);
console.log(`Pending: ${overview.pending}`);

Traffic Analytics

Time-series data tracking visitor behavior:
interface TrafficDataPoint {
  date: string;       // Date in YYYY-MM-DD format
  views: number;      // Page views
  users: number;      // Unique visitors
  sessions: number;   // User sessions
}

// Example data
const trafficData = [
  { date: '2024-01-01', views: 1250, users: 340, sessions: 420 },
  { date: '2024-01-02', views: 1380, users: 365, sessions: 445 },
  // ...
];
import { getEstadisticasPorMes } from '@/services/postsService';

// Get traffic for last 12 months
const monthlyStats = await getEstadisticasPorMes(12);

// Get traffic for last 6 months
const halfYearStats = await getEstadisticasPorMes(6);

Post Performance

Top Posts

Identify your best-performing content:
interface TopPost {
  id: number;
  title: string;
  views: number;
  likes: number;
  comments: number;
  shares: number;
}
import { getPostsPopulares } from '@/services/postsService';

// Get top 10 most viewed posts
const popular = await getPostsPopulares(10);

popular.forEach(post => {
  console.log(`${post.title}: ${post.views} views`);
});
Posts with recent high engagement:
import { getPostsTrending } from '@/services/postsService';

const trending = await getPostsTrending(5);

Most Shared Posts

import { getPostsMasCompartidos } from '@/services/postsService';

const mostShared = await getPostsMasCompartidos(10);

Post Engagement Metrics

import { getPostsConEngagement } from '@/services/postsService';

const highEngagement = await getPostsConEngagement(20);

// Each post includes:
// - views: Total page views
// - likes: Total likes received
// - comments: Comment count
// - shares: Social shares
// - readTime: Average time spent

Posts Needing Attention

Find content that needs engagement:
import { getPostsSinComentarios } from '@/services/postsService';

// Posts with zero comments
const needsEngagement = await getPostsSinComentarios();
console.log(`${needsEngagement.length} posts have no comments`);

Content Analytics

Deep insights into content performance:
interface ContentAnalytics {
  publishedPosts: number;              // Total published
  avgViewsPerPost: number;             // Average views
  engagementRate: number;              // Engagement %
  postsByCategory: CategoryData[];     // Category breakdown
  performanceData: CategoryPerformance[]; // Category metrics
  topAuthors: TopAuthor[];             // Best authors
}

Category Performance

import { getCategoriesEngagement } from '@/services/categoriesService';

const categoryStats = await getCategoriesEngagement();

// Returns engagement metrics per category:
// [
//   { category: 'Technology', views: 15000, engagement: 8.5 },
//   { category: 'Marketing', views: 12000, engagement: 7.2 },
//   ...
// ]

Top Performing Categories

import { getCategoriesMejorRendimiento } from '@/services/categoriesService';

const topCategories = await getCategoriesMejorRendimiento();

Category Statistics

import { getCategoriesStats } from '@/services/categoriesService';

const stats = await getCategoriesStats();
// Returns:
// {
//   total: 20,
//   active: 18,
//   inactive: 2,
//   totalPosts: 500
// }

Author Analytics

Track author performance:
interface TopAuthor {
  id: number;
  name: string;
  avatar: string;
  postsCount: number;
  totalViews: number;
  engagementRate: number;
}

Author Performance

import { getMejorRendimientoPorAutor } from '@/services/postsService';

// Get top 5 posts by specific author
const authorBest = await getMejorRendimientoPorAutor(authorId, 5);

authorBest.forEach(post => {
  console.log(`${post.title}: ${post.views} views, ${post.likes} likes`);
});

User Analytics

Comprehensive user metrics:
interface UsersAnalytics {
  totalUsers: number;              // All registered users
  activeUsers: number;             // Recently active
  newUsers: number;                // New this period
  retentionRate: number;           // User retention %
  activityData: UserActivityData[]; // Activity timeline
  roleDistribution: RoleDistributionData[]; // Users by role
}

Role Distribution

interface RoleDistributionData {
  name: string;        // Role name
  count: number;       // User count
  percentage: number;  // % of total
  color: string;       // Display color
}

// Example data
const roleStats = [
  { name: 'Comentador', count: 450, percentage: 75, color: '#6B7280' },
  { name: 'Autor', count: 80, percentage: 13.3, color: '#F59E0B' },
  { name: 'Editor', count: 40, percentage: 6.7, color: '#2563EB' },
  { name: 'Administrador', count: 30, percentage: 5, color: '#DC2626' }
];

Comment Analytics

Comment Statistics

import { getCommentsStats } from '@/services/commentsService';

const commentStats = await getCommentsStats();
// Returns:
// {
//   total: 1247,
//   approved: 1180,
//   pending: 45,
//   spam: 22
// }

Top Commented Posts

import { getTopCommentedPosts } from '@/services/commentsService';

const mostDiscussed = await getTopCommentedPosts(10);

mostDiscussed.forEach(post => {
  console.log(`${post.title}: ${post.commentCount} comments`);
});

Most Active Commenters

import { getMostActiveCommenters } from '@/services/commentsService';

const topCommenters = await getMostActiveCommenters(10);

topCommenters.forEach(user => {
  console.log(`${user.name}: ${user.commentCount} comments`);
});

Performance Metrics

Technical performance tracking:
interface PerformanceAnalytics {
  metricsData: PerformanceMetric[];   // Performance timeline
  trafficSources: TrafficSource[];    // Traffic sources
}

interface PerformanceMetric {
  date: string;
  pageSpeed: number;      // Load time (ms)
  engagement: number;     // Time on page (seconds)
  bounceRate: number;     // Bounce rate %
}

interface TrafficSource {
  name: string;           // Source name
  visitors: number;       // Visitor count
  percentage: number;     // % of total traffic
}

Keyword Analytics

Track keyword usage and performance:
import { getKeywordsMasUsadas } from '@/services/postsService';

// Get top 50 most used keywords
const topKeywords = await getKeywordsMasUsadas(50);

topKeywords.forEach(keyword => {
  console.log(`${keyword.keyword}: used in ${keyword.count} posts`);
});

Role-Based Analytics Access

Analytics visibility varies by user role:
import { getAnalyticsData } from '@/services/analyticsService';

// Get analytics filtered by user role
const analytics = await getAnalyticsData(userRole, '30d');

// Role-based access:
// - Creador: Full platform analytics
// - Administrador: Full analytics
// - Editor: Content and moderation analytics
// - Escritor: Own content only
// - Autor: Own posts only
// - Comentador: No analytics access
The analytics service automatically filters data based on user permissions. Writers and Authors only see statistics for their own content.

Time Range Filtering

Filter analytics by time period:
// Available time ranges
const timeRanges = ['7d', '30d', '90d', '1y'];

// Get analytics for specific period
const weeklyAnalytics = await getAnalyticsData(userRole, '7d');
const monthlyAnalytics = await getAnalyticsData(userRole, '30d');
const yearlyAnalytics = await getAnalyticsData(userRole, '1y');

Exporting Analytics

Export analytics data in multiple formats:
import { exportAnalyticsData } from '@/services/analyticsService';

// Export as CSV
const csvUrl = await exportAnalyticsData(userRole, '30d', 'csv');

// Export as PDF report
const pdfUrl = await exportAnalyticsData(userRole, '30d', 'pdf');

// Download the exported file
window.open(csvUrl, '_blank');

Real-time Analytics

View Tracking

Track page views in real-time:
import { incrementarVista } from '@/services/postsService';

// Track when user views a post
await incrementarVista(postId, userId, ipAddress);

Engagement Tracking

Monitor user interactions:
import { darLike, quitarLike } from '@/services/postsService';
import { likeComment } from '@/services/commentsService';

// Track post likes
await darLike(postId, userId);

// Track comment likes
await likeComment(commentId);

Analytics Dashboard Example

Complete dashboard implementation:
import { 
  getDashboardOverview,
  getPostsPopulares,
  getEstadisticasPorMes 
} from '@/services/postsService';
import { getCommentsStats } from '@/services/commentsService';
import { getCategoriesStats } from '@/services/categoriesService';

async function loadDashboard() {
  // Load all analytics data
  const [overview, popular, monthly, comments, categories] = await Promise.all([
    getDashboardOverview(),
    getPostsPopulares(5),
    getEstadisticasPorMes(6),
    getCommentsStats(),
    getCategoriesStats()
  ]);
  
  return {
    overview,
    topPosts: popular,
    monthlyTrends: monthly,
    commentStats: comments,
    categoryStats: categories
  };
}

Key Performance Indicators (KPIs)

Content KPIs

  • Average views per post
  • Engagement rate
  • Publishing frequency
  • Content quality score

Audience KPIs

  • Active user count
  • User retention rate
  • Comment participation
  • Return visitor rate

Growth KPIs

  • Monthly traffic growth
  • New user acquisition
  • Content library growth
  • Social share growth

Engagement KPIs

  • Average time on page
  • Comments per post
  • Like rate
  • Share rate

Best Practices

Data Collection

  • Track all user interactions
  • Maintain data accuracy
  • Clean spam data regularly
  • Archive historical data

Analysis

  • Review metrics weekly
  • Identify content trends
  • Compare time periods
  • Set realistic goals

Optimization

  • Focus on high-performers
  • Learn from top content
  • Test different formats
  • Optimize low performers

Reporting

  • Create regular reports
  • Share insights with team
  • Track goal progress
  • Document improvements

Build docs developers (and LLMs) love