Overview
The OneSignal + Google Cloud SQL integration enables automatic syncing of custom events from your Cloud SQL database to OneSignal. This allows you to trigger automated Journeys and personalized messaging campaigns based on user behavioral data stored in your managed PostgreSQL database.Requirements
- Access to Custom Events (currently in beta)
- Updated Account Plan (not available on free apps).
Google Cloud SQL
- Cloud SQL for PostgreSQL instance (version 11 or higher recommended)
- Database access with read permissions for event tables
- Network connectivity from OneSignal to your Cloud SQL instance
- Cloud SQL Auth proxy for secure connections (recommended)
Setup
1
Configure Cloud SQL database access
Create a dedicated user for OneSignal with read-only access to event tables:
2
Configure network access
Ensure OneSignal can connect to your Cloud SQL instance:Option 1: Authorized Networks (Public IP)
- In Google Cloud Console, go to SQL > Instances
- Select your instance → Connections → Networking
- Add OneSignal IP addresses to Authorized networks
- Configure your Cloud SQL instance with a private IP
- Use Cloud SQL Auth Proxy for secure connections
- Ensure proper VPC peering or firewall rules
- Download and configure the Cloud SQL Auth Proxy
- Use service account authentication
- Connect through secure proxy tunnel
3
Set up Cloud SQL Auth Proxy (recommended)
For enhanced security, use Cloud SQL Auth Proxy:Create a service account with Cloud SQL Client role:
4
Add integration in OneSignal
In OneSignal, go to Data > Integrations and click Add Integration.Select Google Cloud SQL and provide:
- Instance Connection Name:
PROJECT_ID:REGION:INSTANCE_ID
- Database Name: Your event database name
- Username:
onesignal_reader
- Password: The password created in Step 1
- SSL Mode:
require
(recommended for security) - Connection Type: Choose between Direct, Auth Proxy, or Private IP
5
Configure event data queries
Define the SQL query to retrieve event data from your Cloud SQL database:Ensure your event tables include:
- Event name/type (String)
- User identifier (String)
- Event timestamp (Timestamp)
- Event properties (JSON/JSONB)
6
Test the connection
Click Test Connection to verify OneSignal can connect to your Cloud SQL instance and execute the event query successfully.
Event data mapping
Map your to OneSignal’s custom events format:OneSignal Field | Description | Required | |
---|---|---|---|
name | event_name | Event identifier | Yes |
external_id | user_id | User identifier | Yes |
timestamp | event_timestamp | When event occurred | No |
properties | event_data | No |
Advanced Configuration
Connection Pooling
Optimize database connections for high-volume event syncing:Query Optimization
Improve event query performance:JSON Data Handling
If using JSONB for event properties, optimize JSON queries:Monitor your Cloud SQL instance’s performance when OneSignal queries event data. Consider using read replicas for analytics workloads to avoid impacting production performance.