Overview
The Chat Analytics component provides comprehensive insights into how users interact with chat components across your platform. It helps educators and administrators understand usage patterns, identify popular topics, measure engagement levels, and make data-driven decisions to improve the learning experience.
Creating a Chat Analytics Component
import StudyfetchSDK from '@studyfetch/sdk' ;
const client = new StudyfetchSDK ({
apiKey: 'your-api-key' ,
baseURL: 'https://studyfetchapi.com' ,
});
const analyticsComponent = await client . v1 . components . create ({
name: 'Platform Chat Analytics Dashboard' ,
type: 'chat_analytics' ,
config: {
chatComponentId: 'chat-comp-123' ,
autoRefresh: true ,
dateRange: 30 ,
enableExport: true ,
refreshInterval: 5 ,
showSummary: true ,
showTopics: true ,
showUserStats: true
}
});
console . log ( 'Chat Analytics component created:' , analyticsComponent . _id );
Configuration Parameters
Name of the chat analytics component
Configuration options for the chat analytics component ID of the chat component to analyze
Enable auto-refresh of analytics data
Default date range in days for analytics display
Enable CSV export functionality
Refresh interval in minutes (minimum: 1, maximum: 60)
Show summary section in analytics dashboard
Show top topics analysis section
Show user statistics and activity patterns
Response
{
"_id" : "comp_123abc" ,
"name" : "Platform Chat Analytics Dashboard" ,
"type" : "chat_analytics" ,
"status" : "active" ,
"config" : {
"chatComponentId" : "chat-comp-123" ,
"autoRefresh" : true ,
"dateRange" : 30 ,
"enableExport" : true ,
"refreshInterval" : 5 ,
"showSummary" : true ,
"showTopics" : true ,
"showUserStats" : true
},
"createdAt" : "2024-01-15T10:00:00Z" ,
"updatedAt" : "2024-01-15T10:00:00Z" ,
"organizationId" : "org_456def" ,
"usage" : {
"interactions" : 0 ,
"lastUsed" : null
}
}
Embedding This Component
Once you’ve created a Chat Analytics component, you can embed it on your website using the embedding API.
Generate Embed URL
const embedResponse = await client . v1 . components . generateEmbed ( analyticsComponent . _id , {
// User tracking
userId: 'user-456' ,
studentName: 'Jane Smith' , // Student name for display
groupIds: [ 'class-101' , 'class-102' ],
sessionId: 'session-789' ,
// Dimensions
width: '100%' ,
height: '800px' ,
// Token expiry
expiryHours: 24
});
Embed in Your HTML
< iframe
src = "https://embed.studyfetch.com/component/comp_123abc?token=..."
width = "100%"
height = "800px"
frameborder = "0"
allow = "clipboard-write"
style = "border: 1px solid #e5e5e5; border-radius: 8px;" >
</ iframe >