Overview
Automate data uploads to Permutive using the GCS service account credentials provided when you created your import. This guide covers authenticating with service account credentials and scripting uploads for automated data pipelines.Prerequisites:
- A GCS import already created in Permutive
- Service account credentials (JSON key file) from your import settings
- Your bucket path and folder structure
gsutilCLI or Google Cloud SDK installed
When to Use Programmatic Upload
Programmatic upload is ideal for:- Regular CRM syncs: Daily or weekly uploads of customer segments
- Partner data feeds: Automated ingestion from data partners
- Pipeline integration: Upload as part of ETL/ELT workflows
- Scheduled jobs: Cron jobs, Airflow DAGs, or other schedulers
Getting Your Credentials
Service account credentials are provided when you create a GCS import:- Navigate to Connectivity > Imports in the Permutive Dashboard
- Select your import
- Download the service account JSON key file
- Note your bucket path
Setup Steps
Authenticate with Service Account
Activate the service account using your JSON key file:Alternatively, set the environment variable for SDK authentication:
Verify Access
Test that you can list the bucket contents:If this succeeds, you have proper access configured.
Prepare Your Data File
Create your data file in the correct format and compress it:This creates
audience_data.tsv.gz ready for upload.Code Examples
Bash Script
A reusable script for scheduled uploads:Python Script
Using the Google Cloud Storage Python SDK:Scheduling Uploads
Cron (Linux/macOS)
Add to your crontab for daily uploads at 2 AM:Apache Airflow
Example DAG task:Best Practices
- Use descriptive filenames: Include dates or timestamps (e.g.,
audience_2024-01-15.tsv.gz) - Implement error handling: Check upload success and retry on transient failures
- Log uploads: Maintain audit trails of what was uploaded and when
- Validate before upload: Check file format and size before uploading
- Monitor processing: Verify files are processed successfully in the Dashboard
- Rotate credentials: Periodically rotate service account keys for security
Troubleshooting
Permission denied errors
Permission denied errors
The service account may lack write permissions to the bucket.Solution: Verify you’re using the correct service account JSON file provided by Permutive. The credentials may have expired or been regenerated—check with your Permutive representative if needed.
gsutil command not found
gsutil command not found
The Google Cloud SDK may not be installed or not in your PATH.Solution: Install the Google Cloud SDK and ensure
gsutil is available in your PATH. Run gcloud components update to ensure you have the latest version.Large files fail to upload
Large files fail to upload
Network timeouts or interruptions can cause large uploads to fail.Solution: Use
gsutil -m for parallel uploads. For very large files, consider splitting into multiple smaller files. Enable resumable uploads with gsutil -o GSUtil:resumable_threshold=0.Files uploaded but not processed
Files uploaded but not processed
Files may not be in the correct format or may be missing taxonomy entries.Solution: Verify file format (tab-separated, gzip compressed with
.gz extension). Check that all segment codes exist in your taxonomy. Monitor the import status in the Dashboard for processing errors.