{"id":50336859,"url":"https://github.com/localytics/services-campaigns-api-script","last_synced_at":"2026-05-29T14:01:21.641Z","repository":{"id":343689538,"uuid":"1145963064","full_name":"localytics/services-campaigns-api-script","owner":"localytics","description":"This repository utilizes the Localytics campaigns API to create multiple dashboard campaigns","archived":false,"fork":false,"pushed_at":"2026-03-11T11:02:00.000Z","size":77,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-03-11T17:20:20.909Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/localytics.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-01-30T12:50:59.000Z","updated_at":"2026-03-11T11:02:05.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/localytics/services-campaigns-api-script","commit_stats":null,"previous_names":["localytics/services-campaigns-api-script"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/localytics/services-campaigns-api-script","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/localytics%2Fservices-campaigns-api-script","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/localytics%2Fservices-campaigns-api-script/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/localytics%2Fservices-campaigns-api-script/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/localytics%2Fservices-campaigns-api-script/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/localytics","download_url":"https://codeload.github.com/localytics/services-campaigns-api-script/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/localytics%2Fservices-campaigns-api-script/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33655441,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-29T02:00:06.066Z","response_time":107,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-05-29T14:01:20.808Z","updated_at":"2026-05-29T14:01:21.623Z","avatar_url":"https://github.com/localytics.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Localytics Campaigns API template script\n\nThis repository contains a simple Python script that creates **Push Campaigns** in the Localytics dashboard using the Localytics **Campaigns API**.\n\nThe script is designed to:\n\n- Define a reusable **push campaign template**\n- Loop through a list of `app_key` values and their associated audiences\n- Apply per-app custom tweaks (optional overrides)\n- Create one campaign per app automatically\n\nThis makes it easy to launch the same campaign across multiple Localytics apps without manually recreating it in the dashboard, and with minimal configurational overhead.\n\nExample output:\n\n```\n✅ Created campaign for app app-1-key\n✅ Created campaign for app app-2-key\n```\n\n---\n\n## Repository Structure\n\n```\nservices-campaigns-api-script-master/\n├── run.py          # Main script that executes the API requests\n├── config.py       # campaign template + list of app keys\n├── .env            # API credentials\n└── README.md\n```\n\n---\n\n## Requirements\n\n### 1. Install Python\n\n---\n\n#### macOS\n\n1. Download Python from: https://www.python.org/downloads/mac-osx/\n\n2. Run the installer  \n\n---\n\n#### Windows\n\n1. Download Python from: https://www.python.org/downloads/windows/\n\n2. Run the installer  \n3. **Important:** Check the box while installing: ✅ *Add Python to PATH*\n\n---\n#### Verify installation\n\nOn Mac, open terminal and run the command below:\n\n```powershell\npython3 --version\n```\nOn Windows, open Command Prompt and run the command below:\n\n```powershell\npython --version\n```\n\n#### Note: This script was tested against Python 3\n---\n\n### 2. Install Dependencies\n\nThis script requires two Python packages:\n\n- `requests`\n- `python-dotenv`\n\nInstall them by opening terminal and running following command:\n\n```bash\npip3 install -r requirements.txt\n```\nOn Windows:\n\n```bash\npip install -r requirements.txt\n```\n\n---\n\n## Script Setup Instructions\n\nDownload and unzip the repository files, then follow the instructions below.\n\n### 1. Open .env file, add your Localytics API credentials and Org ID\n\n```env\nAPI_KEY = your_api_key_here\nAPI_SECRET = your_api_secret_here\nORG_ID = 123456\n```\n\n---\n\n### 2. Modify config.py file\n\n`config.py` contains a basic Push campaign template object which creates a campaign targeting a saved audience. Please review this template object thoroughly, as this defines every configuration in your campaign, starting from the campaign's name and goal, and until the desired campaign scheduling, just like the dashboard.\n\nYou can modify the template object to match your desired campaign. e.g. change the push message title and body, as well as the conversion event for your campaign.\n\nFor advanced modifications to the campaign template object, please refer to the [Campaigns API documentation](https://docs.localytics.com/campaigns_audiences_api.html) for clarification on the values accepted by the Campaigns API when modifying the template.\n\n---\n\n#### App Keys\n\nBelow the campaign_template, you will see a list of apps in the apps_config object. These are the apps which the script loops through to create a campaign for each app, targeting the specified audience for that app. \n\nReplace the app_key and audience_id values with the proper values. You can add as many apps as you need.\n\n```python\napps_config = [\n    {\n        \"app_key\": \"app-1-key\",\n        \"audience_id\":123456\n    },\n    {\n        \"app_key\": \"app-2-key\",\n        \"audience_id\":654321\n    }\n    # add more apps here\n]\n```\n\n#### Notes on apps_config: \n\n- You will find the App key for each app in the dashboard's Settings page\n\n- Make sure the audience_id specified under each app is accurate. If an audience with the specified audience ID does not exist for that app, the campaign will not be created for that app.\n\n- You can double check an audience ID through the dashboard's Audiences page.\n\n---\n\n# Running the Script\n\nOnce everything is configured, follow the steps below to run the script:\n\n- Open terminal\n- Navigate to where you saved the downloaded repository files using the `cd folder_path` command. (an example is shown below)\n- Run the script using the command `python run.py`\n\nSince the script is saved inside my Downloads folder, I ran the following command in terminal to navigate to the script: \n\n`cd Downloads\\services-campaigns-api-script-master`\n\nFollowed by the command to run the script:\n\n`python3 run.py`\n\nOn Windows:\n\n`python run.py`\n\n\n```\nC:\\Users\\username\u003ecd Downloads\\services-campaigns-api-script-master\nC:\\Users\\username\\Downloads\\services-campaigns-api-script-master\u003epython run.py\n✅ Created campaign for app \u003credacted\u003e\n✅ Created campaign for app \u003credacted\u003e\n\nC:\\Users\\username\\Downloads\\services-campaigns-api-script-master\u003e\n```\nThe script will create a push campaign for every app listed in `apps_config`.\n\n\n---\n\n# Optional Overrides\n\nIn the apps_config object, you can `override` any of the campaign_template objects for each app separately. So objects such as conversion_event, audiences, creatives, etc.\n\nUtilizing this would be beneficial if you need to send the same campaign for multiple apps, but with small changes between each app, such as a slightly different creative message or a different conversion event.\n\nThe example below shows how you can override the creative as well as the conversion event for an app using `override`.\n\n```python\napps_config = [\n\n    # app 1 config\n    {\n        \"app_key\": \"app-1-key\",\n        \"audience_id\":112233,\n        \"override\": {\n            \"creatives\": [\n                            {\n                                \"build_attributes\": {\n                                    \"push_title\": \"Hello!\",\n                                    \"push_message\": \"Customized message for app 1\",\n                                }\n                            }\n                        ],\n            \"conversion_event\": {\n                \"event_name\": \"Purchase Completed\"\n            }\n        }\n    },\n    # app 2 config\n    {        \n        \"app_key\": \"app-2-key\",\n        \"audience_id\":223344,\n        \"override\": {\n            \"creatives\": [\n                            {\n                                \"build_attributes\": {\n                                    \"push_title\": \"Hello!\",\n                                    \"push_message\": \"Customized message for app 2\",\n                                }\n                            }\n                        ],\n            \"conversion_event\": {\n                \"event_name\": \"Cart Abandoned\"\n            }\n        }\n    }\n\n    # Add more apps here\n]\n```\n\n\n#### Notes About Override:\n\nOverrides will replace the entire top level object with the one you specify, so make sure you include all required parameters of an object when you override. That means overriding something like `creatives` will replace the entire creatives block for that app.\n\nThis is intentional for simplicity.\n\n---\n\n# Future Improvements\n\nPossible future upgrades include:\n\n- Fetching audiences to verify they properly match app IDs before creating campaigns\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flocalytics%2Fservices-campaigns-api-script","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flocalytics%2Fservices-campaigns-api-script","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flocalytics%2Fservices-campaigns-api-script/lists"}