https://github.com/activecampaign/example-subscription_form_embed
ActiveCampaign Subscription Form API Script: Embed and customize your forms on any site.
https://github.com/activecampaign/example-subscription_form_embed
Last synced: about 1 year ago
JSON representation
ActiveCampaign Subscription Form API Script: Embed and customize your forms on any site.
- Host: GitHub
- URL: https://github.com/activecampaign/example-subscription_form_embed
- Owner: ActiveCampaign
- Created: 2013-01-07T20:15:39.000Z (over 13 years ago)
- Default Branch: master
- Last Pushed: 2015-11-13T22:49:03.000Z (over 10 years ago)
- Last Synced: 2025-04-01T16:09:28.005Z (about 1 year ago)
- Language: PHP
- Size: 801 KB
- Stars: 6
- Watchers: 11
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
ActiveCampaign Subscription Form API Script: Embed and customize your forms on any site.
## Requirements
1. [Our PHP API library](https://github.com/ActiveCampaign/activecampaign-api-php)
2. jQuery (if using the Ajax option, or loading existing contact details)
## Installation and Usage
You can install **example-subscription_form_embed** by downloading (or cloning) the source.
Input your ActiveCampaign URL and API Key. Example below:
define("ACTIVECAMPAIGN_URL", "YOUR ACTIVECAMPAIGN URL");
define("ACTIVECAMPAIGN_API_KEY", "YOUR ACTIVECAMPAIGN API KEY");
Make sure the path to the PHP library is correct:
require_once("../../activecampaign-api-php/includes/ActiveCampaign.class.php");
Set up your subscription form embed parameters:
$form_embed_params = array(
"id" => 1026,
"action" => "",
"ajax" => 1,
"css" => 1,
);
Here is a breakdown of each:
* `id`: The ID of your subscription form.
* `action`: The URL that your subscription form will post data to (leave out this parameter completely if you want to post it to the default location, or set to empty string to post to the same page the script is running).
* `ajax`: `0` or `1`. Whether or not the form submits via standard page reload, or Ajax (requires jQuery).
* `css`: `0` or `1`. Whether or not to include (or remove) the default CSS that comes with each subscription form.
Finally, decide whether to perform a sync or standard add/edit:
// set to 1 to sync
$sync = 0;
A sync does not require a subscriber ID, and will automatically add or edit, depending if they exist already (based on the email address). If you wish to simply perform an ADD (no edit), delete this portion of `Form.class.php`:

To load an existing contact's details in your form (name, email, and custom field values), include the **contact hash** in the URL (IE: `index.php?hash=ihfsaduh038d3q...`).

[Learn more about syncing subscribers](http://www.activecampaign.com/blog/sync-subscribers-with-our-api/).
## Documentation and Links
* [Full API documentation](http://activecampaign.com/api)
* [Blog post: Advanced Subscription Form Integration](http://www.activecampaign.com/blog/advanced-subscription-form-integration/)
## Reporting Issues
We'd love to help if you have questions or problems. Report issues using the [Github Issue Tracker](https://github.com/ActiveCampaign/example-subscription_form_embed/issues) or email help@activecampaign.com.