We all started somewhere! Share your experience on the Get Advice: Let's Get Started Sweepstakes thread and be entered to win a $100 credit on your Constant Contact account.

Add contacts from Mobile Banner

AndrewH131
Regular Participant

Add contacts from Mobile Banner

Hey there,

 

I'm running some mobile ads whereby the user has to enter their email address.

 

Once they do this, I want this email address to be sent to constant contact who will then send out my email to that specific email address.

 

Is this possible? The issue I'm having is that in the Ad Tool (Celtra) it only gives me the option of sending that specific email address to a custom URL.

 

THanks
Andrew 

18 REPLIES 18
AndrewH131
Regular Participant

Please note, that the mobile banner ad is a static unit, so I don't have html functionality behind it.

 

The way the serving platform works is it gives me an email field and then allows me to submit that info to a custom url.

Hey Andrew,

 

The best option for you would probably be to set up a call to our API on your website, then use the custom URL they want you to fill in to navigate to your site. You can then grab the information on your end, and send it through to our system. We don't allow direct POSTing to our site, due to the security risks.

 

You'll definitely want to be cautious, though, when dealing with this type of integration. We do have a welcome email that will automatically be sent out when a contact is created in the account as ACTION_BY_CONTACT, but our scheduling system is more built to accomidate newsletter (one-to-many) sending, and less of transactional emails. As long as the user is aware they are signing up for emails, and you have the appropriate information in the welcome email, you should be alright.

Nick Galbraith
Support Engineer
AndrewH131
Regular Participant

THanks for the reply,

 

I am able to use 3 lines of javascript within the ad creator.

 

Is there something I can do with the javascript as a work around?

 

Cheers

Andrew

Hey Andrew,

 

Unfortunately, Javascript alone wouldn't be able to communicate with our API. You can definitely utilize the Javascript into your own web app, but it would need a proper authentication connection to pass the information, which would need a server-side language such as PHP, ASP, or others.

Nick Galbraith
Support Engineer
AndrewH131
Regular Participant

Thanks Nick,

 

So my developers wrote some code whereby the Mobile ad sends the email address to our server which should be pinginn your API and sending out the email. We created a custom list in our account, however names are not being added to the list...Can I post the URL Here to show you?

You can definitely post the code that your developers have written up, but depending on the content, you may not want to post it in a public forum. Feel free to post it here if you feel it's okay, or you can email the files to webservices@constantcontact.com, and we can take a look for you.

Nick Galbraith
Support Engineer
AndrewH131
Regular Participant

THanks Nick,

Just emailed them to you 

AndrewH131
Regular Participant

Success!

 

Hey Nick, my mobile ads are now loading directly into my list which is great (Turns out we had to tweak the PHP file slightly). THe only thing now is that it's not automatically firing out the email once to the new contact, once they are being added.

 

Any thoughts here?

Well not quite Success,

 

THe list is now being populated with my names. However, I've now been told that in order to automatically email the user as they enter the list, I have to use autoresponder, which I can't because I've got a custom coded email.

 

Arhhhh....surely there is a way around this.

 

THanks

andrew

The welcome email should still be queued when a contact is added through the API. As long as the creation is processed as ACTION_BY_CONTACT, it should be going out when adding new contacts. The Autoresponder will work as well, if you felt like creating them through the UI.

I'll be able to look through the code you've sent to see how the information is being passed, and I can get back to you via email with what I find. If you happen across any progress on this before you hear back from me, feel free to post here.
Nick Galbraith
Support Engineer
AndrewH131
Regular Participant

Hey Nick,

 

So this is the script that we have from our Server:

 

As I mentioned, it's correctly adding names to the list, however, once the names are in the list, my custom coded email is not being sent out. Bear in mind, there is no welcome email, all I want to happen is for my custom email to automaticallly be sent to the respective email address.

 

I've copied the script here, as I can't see how to attach the php file.

 

<?php
header('Content-Type: text/html; charset=UTF-8');
include_once('cc_class.php');
$ccContactOBJ = new CC_Contact();
$ccListOBJ = new CC_List();

try {

switch ($_SERVER['REQUEST_METHOD']) {
case 'OPTIONS':
header('HTTP/1.1 200 OK');
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: POST, OPTIONS');
header('Access-Control-Allow-Headers: ' . $_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']);
header('Access-Control-Max-Age: 3600');
break;

case 'POST':
header('HTTP/1.1 200 OK');
header('Access-Control-Allow-Origin: *');

// Save data in $_POST
error_log(var_export($_POST, true));
break;

default:
header('HTTP/1.1 405 Method Not Allowed');
header('Allow', 'POST, OPTIONS');
}

if (isset($_POST["Email"])) {

$postFields = array();
$postFields["email_address"] = $_POST["Email"];
$postFields["first_name"] = "";
$postFields["last_name"] = "";
$postFields["middle_name"] = "";
$postFields["home_number"] = "";
$postFields["address_line_1"] = "";
$postFields["address_line_2"] = "";
$postFields["address_line_3"] = "";
$postFields["city_name"] = "";
$postFields["state_code"] = "";
$postFields["state_name"] = "";
$postFields["country_code"] = "";
$postFields["zip_code"] = "";
$postFields["sub_zip_code"] = "";
$postFields["mail_type"] = "HTML";
$postFields["lists"] = $postFields["lists"] = array("http://api.constantcontact.com/ws/customers/andrew%40ironhorseinteractive.com/lists/2");

$contactXML = $ccContactOBJ->createContactXML(null,$postFields);

if (!$ccContactOBJ->addSubscriber($contactXML)) {
$error = true;
} else {
$error = false;
$_POST = array();
}

}

} catch (Exception $e) {
echo "<span style='color:red;'>" . $e . "</span>";
}
?>

Sending out an email after a contact has signed up would require another process in your PHP app, as well as extra permissions for your API key. You would need to add the contact to its own individual list, then create/copy the email, then schedule it. This would take a few extra steps, and it would have about a 15 minute delay.

 

I would suggest logging in to your Constant Contact account and editing the welcome email with your code. This way, you have a single process of adding the contact, and the email goes out automatically, without having to create new lists and schedule the emails.

 

Two other side notes:

- If you would like to proceed with scheduling your custom emails to the new contacts, send us an email to request changing permissions on your key: webservices@constantcontact.com

- I notice you're using the cc_class from our sample form. This function is more used as an example, and doesn't have much room to work with when developing. I'd suggest looking into using the PHP Wrapper Library instead.

Nick Galbraith
Support Engineer
AndrewH131
Regular Participant

Hey,

 

Not sure I follow you: Are you saying that all I have to do is convert my welcome email into my Custom Email and that will automatically send everytime somebody is added to the list?

 

THanks

Andrew

AndrewH131
Regular Participant

Hey Nick,

 

ANy news on this. I'm busy trying to update my welcome email, but according to this link the welcome email won't send out automatically if I'm adding contacts manually (or is that not my case?)

 

http://constantcontact.custhelp.com/app/answers/detail/a_id/4505/~/difference-between-the-welcome-em...

That FAQ is specifically talking about adding the contacts through the UI, not through an API call. If the connection creates the contacts as ACTION_BY_CONTACT, they will receive the welcome email.

Nick Galbraith
Support Engineer
AndrewH131
Regular Participant

THanks for all your help here Nick,

 

I know you advised earlier against using cc_class.php, but that's what my dev team used....it was in this file that I added 'ACTION_BY_CONTACT'....it was 'ACTION_BY_CUSTOMER'

 

I copied just the first part of the cc class file below..

 

SHould this do the trick?

 

 

<?php
date_default_timezone_set('America/New_York');
/**
* Class that is using REST to communicate with ConstantContact server
* This class currently supports actions performed using the contacts, lists, and campaigns APIs
* @author ConstantContact Dev Team
* @version 2.0.0
* @since 30.03.2010
*/

class CC_Utility {

// FROM HERE YOU MAY MODIFY YOUR CREDENTIALS
var $login = 'andrew@ironhorseinteractive.com'; //Username for your account
var $password = 'ihvconstant'; //Password for your account
var $apikey = '16b8f545-eb11-44ae-95db-22698eac17d5'; // API Key for your account.

// CONTACT LIST OPTIONS
var $contact_lists = array(); // Define which lists will be available for sign-up.
var $force_lists = true; // Set this to true to take away the ability for users to select and de-select lists
var $show_contact_lists = false; // Set this to false to hide the list name(s) on the sign-up form.
// NOTE - Contact Lists will only be hidden if force_lists is set to true. This is to prevent available checkboxes form being hidden.

// FORM OPT IN SOURCE - (Who is performing these actions?)
var $actionBy = 'ACTION_BY_CONTACT'; // Values: ACTION_BY_CUSTOMER or ACTION_BY_CONTACT
// ACTION_BY_CUSTOMER - Constant Contact Account holder. Used in internal applications.
// ACTION_BY_CONTACT - Action by Site visitor. Used in web site sign-up forms.

// DEBUGGING
var $curl_debug = true; // Set this to true to see the response code returned by cURL

// YOUR BASIC CHANGES SHOULD END HERE
var $requestLogin; //this contains full authentication string.
var $lastError = ''; // this variable will contain last error message (if any)
var $apiPath = 'https://api.constantcontact.com/ws/customers/'; //is used for server calls.
var $doNotIncludeLists = array('Removed', 'Do Not Mail', 'Active'); //define which lists shouldn't be returned.

Sweet, looks like it's working!. Yee Ha

 

Thanks for your patience and help Nick

Absolutely! I'm glad things are moving forward. Just let us know if you have any other questions.

Nick Galbraith
Support Engineer
Developer Portal

View API documentation, code samples, get your API key.

Visit Page