Constant Contact - Integration Document

Written By Devin O'Neill ()

Updated at April 16th, 2025

Introduction

Constant Contact is a leading expert in email marketing, providing small businesses with the tools they need to create effective campaigns. With a wide range of easy-to-use tools and features, Constant Contact makes it simple to design and execute successful email marketing strategies.

Default URLs:

Available Functions:

createContact()

This function adds a contact to a specified contact list.

Parameter Name Parameter Description Example
$accessToken The authorization token (see Section 3.7 for details). AcVhQBMMErURVZrJYG9VvaoAQrSL
$listId (required) The ID of the contact list where the contact should be added. 9e6431ae-19e9-11eb-a855-fa163e751802
$email (required) The email address of the contact. somebody@gmail.com
 
$fieldData (required) An array of custom fields that map the contact's details. array(
"first_name"=>"matt",
"birthday_month"=>"08",
"birthday_day"=>"10",
"ef73e0d8-2e86-11eb-9f27-fa163ea6032f"=>"1000",
"f0dadc64-4453-11eb-9523-fa163e56233d"=>"0",
"f0dcbdea-4453-11eb-9523-fa163e56233d"=> "04/03/2010",
"f0de4ea8-4453-11eb-9523-fa163e56233d"=>"1", "f0dfceae-4453-11eb-9523-fa163e56233d"=>"04/03/2020",
"fa664b5c-2e86-11eb-baff-fa163ea6032f"=>"500"
)

updateContact()

This function is used to update an existing contact's information.

Parameter Name Parameter Description Example
$accessToken The authorization token (see Section 3.7 for details). AcVhQBMMErURVZrJYG9VvaoAQrSL
$listId (required) The ID of the contact list where the contact resides. 9e6431ae-19e9-11eb-a855-fa163e751802
$email (required) The email address of the contact to be updated. somebody@gmail.com
$fieldData (required) An array containing the fields to be updated.

array(

fa163ea6032f"=>"1000",

"f0dadc64-4453-11eb-9523-fa163e56233d"=>"0",

"f0dcbdea-4453-11eb-9523-fa163e56233d"=> "04/03/2010",

"f0de4ea8-4453-11eb-9523-fa163e56233d"=>"1",

"f0dfceae-4453-11eb-9523-fa163e56233d"=>"04/03/2020",

"fa664b5c-2e86-11eb-baff-fa163ea6032f"=>"500"

)

addOrUpdateContact()

This method is used to either create a new contact or update an existing one.

Note: The function only updates the fields provided in the $fieldData parameter.

Parameter Name Parameter Description Example
$accessToken The authorization token (see Section 3.7 for details). AcVhQBMMErURVZrJYG9VvaoAQrSL
$apiKey (required) The API key provided by Constant Contact. y5rdwwyggfpbza8znz878wmd
$email (required) The email address of the contact. somebody@gmail.com
$fieldData (required) The array of fields to create or update.

array(

fa163ea6032f"=>"1000",

"f0dadc64-4453-11eb-9523-fa163e56233d"=>"0",

"f0dcbdea-4453-11eb-9523-fa163e56233d"=> "04/03/2010",

"f0de4ea8-4453-11eb-9523-fa163e56233d"=>"1",

"f0dfceae-4453-11eb-9523-fa163e56233d"=>"04/03/2020",

"fa664b5c-2e86-11eb-baff-fa163ea6032f"=>"500"

)

getFields()

This function retrieves all custom fields available for a contact list.

Parameter Name Parameter Description Example
$accessToken The authorization token (see Section 3.7 for details). AcVhQBMMErURVZrJYG9VvaoAQrSL

createFields()

This function creates a custom field for a contact list.

Parameter Name Parameter Description Example
$accessToken The authorization token (see Section 3.7 for details). AcVhQBMMErURVZrJYG9VvaoAQrSL
$fieldLabel The display name of the custom field shown in the UI. Available Points
$fieldType Specifies the type of data the custom field will accept (for example, string, date). String

refreshToken()

Access tokens expire automatically after 2 hours (7,200 seconds). This function is used to obtain a new access token after expiration.

Parameter Name Parameter Description Example
$refresh_token The refresh token (see Section 3.7 for details). FSb0L49mzfthmjZD6yiwLi2hZ0cEOxtBom8cu3fjAH
$client_id The client ID provided by Constant Contact. 94efde99-e3be-491f-8e09-dac1ee9f5588
$client_secret The client secret provided by Constant Contact. Hsne_mQqgQCgaz0-Lkl8XQ

How to Get Access Token and Refresh Token:

To obtain an access token and refresh token, follow these steps:

  1. Visit the following URL:
    https://api.socialannex.com/constant_contact/connect.php?site_id={siteid}
  2. The account owner will be prompted to log in and allow your app to access their account.
  3. After login, the account owner will be redirected to your specified redirect URL with an authorization code appended as a query parameter.
  4. The response will contain both the access_token and refresh_token.

Example URL:

https://api.socialannex.com/constant_contact/connect.php?site_id=54640920

Example Usage of the Class:

$objectCCV3 = new Constantcontactlib();
$email_id = "sa.testint@gmail.com";
$data = array(
"first_name"=>"sa",
"birthday_month"=>"08",
"birthday_day"=>"10",
"ef73e0d8-2e86-11eb-9f27-fa163ea6032f"=>"1000",// Total spent
"f0dadc64-4453-11eb-9523-fa163e56233d"=>"0", //Activities Completed
"f0dcbdea-4453-11eb-9523-fa163e56233d"=> "04/03/2010",// Join date
"f0de4ea8-4453-11eb-9523-fa163e56233d"=>"1", //Optin Status
"f0dfceae-4453-11eb-9523-fa163e56233d"=>"04/03/2020",//Program Anniversary Date
"fa664b5c-2e86-11eb-baff-fa163ea6032f"=>"500"//total saved
);
$client_id="94efde99-e3be-491f-8e09-dac1ee9f5588";
$client_secret_key="Hsne_mQqgQCgaz0-Lkl8XQ";

$listId = "9e6431ae-19e9-11eb-a855-fa163e751802";
$result = $objectCCV3 ->addOrUpdateContact($getToken['access_token'], $listId, $email_id, $data);

Log in to Constant Contact

Create a List

To create a new list, follow these steps:

  1. Navigate to ContactsLists, as shown in the image below.
  2. Click the Create List button.
  3. A popup will appear.
 
  1. Enter the name of your list and click the Add List button.
    This will create the list.

Create a Message

To create a new message, follow these steps:

  1. Navigate to CampaignsCreate, as shown in the image below.
  2. A popup will appear.
  3. Select Email Automation, then click Create Automated Series.
  4. A new window will open.
  5. Enter the name of your series and click the Save button.
  6. Follow the on-screen instructions to create the email.

Steps to Get API Key and Access Token

To get your API Key and Access Token, follow these steps:

  1. Click on My Applications, as shown in the window below.
  2. Click on New Application.
  3. A popup will appear.
  4. Enter the app name and click the Save button.
  5. The next window will open.
  6. Provide the Client ID to Annex Cloud.
  7. Click the Generate Secret button.
 
  1. This will generate your secret key.
  2. Provide the User Client ID and Client Secret to Annex Cloud.