JIMMY DAHLQVIST | 2024-04-17
Serverless website analytics with
Lambda@Edge
@jimmydahlqvist
JIMMY DAHLQVIST
Serverless enthusiast
AWS Ambassador | AWS Community Builder | User Group Leader
Founder of serverless-handbook.com
Head of AWS @ Sigma Technology Cloud
§
Hello, I'm
@jimmydahlqvist
Todays agenda
• Episode I: The Problem Awakens
• Episode II: Birth of a Solution
• Episode III: Revenge of the Gotchas
• Episode IV: A New Refined Solution
• Episode V: The Live Demo Strikes Back
Episode I:
The Problem Awakens
@jimmydahlqvist
Website statistics
• Google Analytics
• Been my tracker for years
• Universal Analytics deprecated
• Way to advanced
• Open Source alternatives
• Plausible and Matomo
• Fathom Analytics
• Not free
@jimmydahlqvist
• I just want Easy way to understand my readers!
• How hard can it be?
• Could I track in the backend?
Episode II:
Birth of a Solution
@jimmydahlqvist
Thoughts
• No client side tracking
• Page, Time, and Country
• Can I use CloudFront?
CloudFront Integration points
@jimmydahlqvist
Lambda@Edge vs CloudFront Functions
Lambda@Edge
• All integration points
• Network access
• Up to 5 or 30 second duration
CloudFront Functions
• Viewer Request / Response
• No network access
• Sub millisecon duration
You can’t combine CloudFront Functions and Lambda@Edge
@jimmydahlqvist
Decoupled and event-driven
• Event-driven solution
• Decouple
• Ingestion
• Storage
• Analytics
Ingestion
Data-store
Analytics
Episode III:
Revenge of the Gotchas
@jimmydahlqvist
Three problems
• Solution failed to deploy, cryptic error message
• There was missing data in Athena
• Page felt sluggish
@jimmydahlqvist
Gotcha
• Lambda@Edge and Functions won’t combine
• Lambda@Edge -> EventBridge high latency
• Glue and new lines
• CloudFront headers in cache policy
Episode IV:
A New Refined Solution
@jimmydahlqvist
Needed to solve
• High Latency
• Time & Date
• Viewer type
A new hope
Episode V:
The Live Demo Strikes Back
@jimmydahlqvist
Serverless Handbook
https://serverless-handbook.com/serverless-web-statistics
@jimmydahlqvist
B
B
@jimmydahlqvist
dahlqvistjimmy
https://serverless-handbook.com
https://jimmydqv.com
THANK YOU

Serverless website analytics with Lambda@Edge