πΉ About
Understanding how users interact with your Oracle APEX application is essential for improving usability, tracking engagement, and making data-driven decisions.
In this blog, weβll learn how to integrate Google Analytics (GA4) with Oracle APEX to track:
β
Page visits
β
User behavior
β
Navigation flow
β
Session analytics
β
Custom events
By the end of this guide, youβll have a fully integrated analytics solution for your Oracle APEX application.
π οΈ Tools and Technologies
- Oracle APEX
- Google Analytics 4 (GA4)
- JavaScript
- Google Tag Manager (Optional)
π Why Use Google Analytics in Oracle APEX?
Google Analytics helps monitor application usage and user behavior.
π― Benefits
β
Track application traffic
β
Understand user behavior
β
Identify popular pages
β
Monitor session duration
β
Track custom actions/events
β
Improve application UX
π What is Google Analytics 4 (GA4)?
GA4 is the latest version of Google Analytics that provides:
β Event-based tracking
β Cross-platform analytics
β Enhanced reporting
β Real-time monitoring
Unlike older Universal Analytics, GA4 focuses on events instead of sessions.
π Step 1: Create Google Analytics Account
Go to:
https://analytics.google.comCreate:
- Analytics Account
- Property
- Data Stream
After setup, Google provides a:
Measurement IDExample:
G-XXXXXXXXXXπ Step 2: Get GA4 Tracking Script
Google Analytics provides a script similar to:
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){
dataLayer.push(arguments);
}
gtag('js', new Date());
gtag('config', 'G-XXXXXXXXXX');
</script>π Step 3: Add Script in Oracle APEX
Go to:
Shared Components β User Interface AttributesUnder:
Desktop β JavaScript β Function and Global Variable DeclarationPaste the GA4 tracking code.
π Alternative Method: Page Level Integration
You can also add the script directly at page level.
Go to:
Page Designer β Page β Execute when Page Loads
Example:
<script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){
dataLayer.push(arguments);
}
gtag('js', new Date());
gtag('config', 'G-XXXXXXXXXX');
</script>π Step 4: Verify Google Analytics Integration
Open your application.
Then in GA4:
Reports β RealtimeYou should see:
β
Active users
β
Current page visits
β
Events triggered
π Step 5: Track Custom Events
One of the most powerful GA4 features is custom event tracking.
π Example: Track Button Click
$('#save_btn').click(function(){ gtag('event', 'save_button_click', { event_category: 'Button', event_label: 'Save Employee', value: 1 }); });π Example: Track Interactive Grid Save
gtag('event', 'ig_save', { event_category: 'Interactive Grid', event_label: 'Employee Grid Save' });π Example: Track Login Activity
gtag('event', 'user_login', { event_category: 'Authentication', event_label: 'APEX Login' });π Step 6: Track Page Navigation
apex.navigation.redirect = function(url){ gtag('event', 'page_navigation', { destination_url: url }); };π Useful Metrics You Can Track
| Metric | Description |
|---|---|
| Page Views | Most visited pages |
| Active Users | Current online users |
| Session Duration | User engagement |
| Events | User interactions |
| Bounce Rate | Exit behavior |
| Device Type | Desktop vs Mobile |
π― Real-World Use Cases
Google Analytics in APEX is useful for:
β Enterprise dashboards
β Employee portals
β Customer self-service apps
β Internal business applications
β Public-facing applications
π₯ Using Google Tag Manager (Optional)
Instead of adding scripts directly in APEX, you can use:
Google Tag Manager (GTM)Benefits:
β
Centralized management
β
No redeployment needed
β
Easier event tracking
β
Better scalability
π Example GTM Script
<!-- Google Tag Manager -->
<script>
(function(w,d,s,l,i){w[l]=w[l]||[];
w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});
var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';
j.async=true;
j.src='https://www.googletagmanager.com/gtm.js?id='+i+dl;
f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-XXXX');
</script>β οΈ Important Considerations
πΉ GDPR / Privacy Compliance
Always inform users if tracking is enabled.
You may need:
β
Cookie consent popup
β
Privacy policy updates
πΉ Avoid Sensitive Data Tracking
Do NOT send:
β Passwords
β Personal information
β Financial data
to Google Analytics.
πΉ Performance
Load scripts asynchronously to avoid slowing down APEX pages.
π Advanced Enhancements
You can extend analytics with:
β Custom dashboards in APEX
β User journey tracking
β Heatmaps
β Conversion funnels
β Error monitoring
β Session replay tools
π Example Architecture
Oracle APEX App β Google Analytics Script β User Interactions β GA4 Event Tracking β Analytics Dashboardπ Conclusion
Integrating Google Analytics with Oracle APEX provides powerful insights into how users interact with your application.
By combining:
β
Oracle APEX
β
Google Analytics 4
β
Event Tracking
β
JavaScript
you can create smarter, data-driven applications with better user experiences.
Whether itβs monitoring employee portals, customer applications, or enterprise dashboards, analytics helps you make informed decisions and continuously improve your applications.
Happy Coding!
Hi, Iβm Ankur Rai, an Oracle APEX Developer with 6+ years of professional experience in building enterprise applications. I specialize in creating scalable and efficient solutions using Oracle APEX, PL/SQL, and SQL to solve real-world business challenges.
I am a 3X Oracle APEX Professional Certified Developer and also an Oracle ACE Associate Member, actively contributing to the Oracle community by sharing knowledge, insights, and best practices. Through my blogs, I aim to help developers learn, grow, and build better Oracle APEX applications together.




