This document contains conceptual information and code samples that you can use when configuring the Web Collect feature. Contact your ExactTarget representative to enable this feature on your account.
This document is intended for business managers, system administrators, and other ExactTarget users who are responsible for enabling the Web Collect functionality by adding required HTML code to your corporate web site.
You can use Web Collect and HTML code incorporated into your web page to allow your web site visitors to subscribe to or unsubscribe from your email publications.
By inserting the code described in this document (with modifications to replace the sample content with content specific to your account data) into your web page, you'll be able to do the following:
The code samples shown in this document are available in text file format for easier copying and pasting. The code sample section of this document contains the download link.
You can use a triggered send to send an automatic email to subscribers who add themselves to lists using the Web Collect feature.
To build your Web Collect page, you'll need the list ID of each exposed subscriber list. Additionally, you'll need to pass your ExactTarget member ID (account ID) in your form. These requirements, along with the supporting pages needed, are described in the following sections.
You can use Web Collect to add names to publication, suppression, and subscriber lists. However, remember that you can only send messages to subscriber lists. The ExactTarget application uses publication and suppression lists in conjunction with data extensions to control unsubscribes; it does not send directly to the subscribers on the publication or subscription list.
For server-side requests, you must include a Content-Type header of "application/x-www-form-urlencoded" in your form. The server does not add this header by default.
For each list that you want to expose to your web site visitors for subscribing to or unsubscribing from, you'll need to obtain the ExactTarget list ID and confirm that the list is defined as a public list.
That list ID must also be included in any opt-in links for triggered email sends. For example, in the link below, you would replace <<LID>> with the list ID number and include it in your transactional send to a subscriber in order to add them to your subscriber list.
http://cl.exct.net/sub_confirm.asp?lst=<<LID>>_HTML&eml=%%EmailAddr_%%&mid=%%MemberID%%
Your Web Collect submission form must include your ExactTarget member ID (MID) as a hidden input field.
You can find your member ID in the upper-right corner of your ExactTarget application, next to your account name. In the following sample illustration, the member ID is 3133.
For this example, the MID would be passed as follows:
<input type="hidden" name="MID" value="3133" />
See the Code Samples section at the end of this document.
You'll need to set up the following supporting pages on the web site containing your Web Collect form. Your Web Collect code will link to these pages.
If you use the S4 instance, you must set up your pages by substituting "cl.s4.exct.net" instead of "cl.exct.net" in the sample code examples shown below.
The Web Collect feature supports the direct submission of data from your client-side Flash application using ActionScript or Flex.
For example, the following sample uses ActionScript 3.0 to submit customer data:
<br><br>
private function sendSubcription():void{<br>
var request:URLRequest = new URLRequest("http://cl.exct.net/subscribe.aspx?lid=LISTID");<br>
var sendVars:URLVariables = new URLVariables();<br>
sendVars.thx = "http://THANKYOUPAGE";<br>
sendVars.err = "http://ERRORPAGE";<br>
sendVars.usub = "http://UNSUBSCRIBE";<br>
sendVars.mid = "MEMBERID";<br>
sendVars.SubAction = "sub_add_update";<br>
sendVars["Email Address"] = emailaddress.text;<br>
sendVars["Full Name"] = fullname.text;<br>
sendVars["Subscriber Key"] = ETSubscriberKey.text;<br>
request.method = URLRequestMethod.POST;<br>
request.data = sendVars;<br>
navigateToURL(request);<br>
}
Your web site can allow your subscribers to update their profile and preference attributes.
Make sure that the attribute field names and types in your submission form exactly match what's defined in your ExactTarget application. To check the data type and other properties of an attribute, go to the attribute's Properties dialog box, which you access from the Subscribers»Profile Management area of the application.
For an example of the attribute fields that you might want to include on your Web Collect form (such as name, email address, or subscriber key), see the Profile Center that ExactTarget displays when a subscriber clicks the "modify profile" link in the emails you send. To see what the Profile Center looks like, go to the Subscribers»Profile Management area of your ExactTarget application and choose the Preview Profile Center option in the toolbar. The Profile Center displays all attributes that are not defined as "hidden" in your account.
The number of attributes you can have in your account and whether you can create new attributes are determined by your account configuration. Contact your ExactTarget account manager if you have questions. For example, you must have the Subscriber Key feature enabled for your account if you wish to use that attribute in conjunction with Web Collect.
Remember: If you're using your web site to allow new subscribers to sign up, you must pass data for all required profile and preference attributes - including those that are defined as "hidden" - for the new subscriber. See the attribute's Properties dialog box to check whether the attribute is required or not. For example, the Email Address attribute is always required:
If the attribute is defined in your ExactTarget account as having restricted values (a drop-down list of all possible values), you need to present each value exactly as it's defined in the application. These values are case-sensitive.
In the following example, the attribute name is Industry, and it's defined as having six possible values. The following code will prompt the user to select an industry from the options given.
<p><b>Industry: </b> <select name="Industry"> <option name = "Industry" value="">Please select an industry.</option> <option name = "Industry" value="Automotive">Automotive</option> <option name = "Industry" value="Banking">Banking</option> <option name = "Industry" value="Call Center">Call Center</option> <option name = "Industry" value="Consultant">Consultant</option> <option name = "Industry" value="Education">Education</option> <option name = "Industry" value="Government">Government</option> </select></p>
If the restricted-value attribute is required and you do not want to expose it to your web site visitors, do not pass the value and the system sets the attribute to the default value.
You define the default value for an attribute on the Data tab of the attribute's Properties dialog box:
If you use an ExactTarget Enterprise account and you want to set up a Web Collect form for your On Your Behalf accounts, the member ID of the account (the channel member ID) is a required input field on your submission form.
<INPUT TYPE="HIDDEN" name="ChannelMemberID" VALUE="OYB account number" />
Use the following steps to find the account number of the On Your Behalf account:
You can offer your web site visitors the option of subscribing to a single list or multiple lists. Existing subscribers can be offered the option of updating their profile data or unsubscribing. Offer existing subscribers the option to unsubscribe from the All Subscriber list to provide a method for subscribers to globally unsubscribe.
Use the SubAction type appropriate to your needs:
| Subaction | Description and Example |
| sub | Allow the visitor to be added to a list only. For example, to add the visitor as a subscriber to a list without updating any profile data, use the following form element:
|
| sub_add_update | Allow the visitor to be added to a list or, if the visitor already belongs to the list, allow the visitor to update his or her profile data. For example, to add a visitor as a subscriber to a list or to allow existing subscribers to update their profile data, use the following form element:
|
| unsub | Allow the visitor to unsubscribe from a list. |
See the Code Samples section at the end of this document.
All errors are passed in the QueryString of the error page URL, with the following variables:
The following table lists the possible error codes and their associated errorControl values, along with a description of each error.
| Error Code | Error Description | Value Returned in errorControl |
| 1, 6, 7 , 9, and 10 | An error has occurred while attempting to save your subscriber information. | Blank. |
| 2 | The list provided does not exist. | Blank. |
| 3 | Information was not provided for a mandatory field. | The name of the required field that the subscriber did not complete. |
| 4 | Invalid information was provided. | The name of the field in which the subscriber entered invalid data. |
| 5 | Information provided is not unique. | The name of the field in which the subscriber entered data that duplicates data already in your database for that field. |
| 8 | Subscriber already exists. | The list ID of the list to which the subscriber already belongs. |
| 12 | The subscriber you are attempting to insert is on the master unsubscribe list or the global unsubscribe list. | The list ID of the unsubscribe list. |
| 14 | The query string contains ETsubscriberKey and the Subscriber Key feature is not enabled on your account. | The name of the field. |
See the Error Codes 4, 10, and 13 troubleshooting section for common reasons behind receiving these errors.
You can set a list's opt-in status and set up confirmation emails through the List Properties dialog box. The opt-in feature applies when a subscriber is added to a list via your Web Collect form.
Follow these steps to view the opt-in status:
http://cl.exct.net/sub_confirm.asp?lst=%%List_%%&eml=%%EmailAddr_%%&mid=%%MemberID
You must first create and publish the landing page before choosing to use it as part of the Web Collect opt-in feature.
The subscriber initially joins the list with an unsubscribed status. The application sends a triggered email, and the subscriber's status changes to subscribed if/when they reply to the triggered email's request for confirmation.
The opt-in behavior that you defined for this list takes effect immediately and is applied to all subscribers added to the list via your Web Collect form in the future.
Here are helpful hints to troubleshoot issues you might encounter.
Issue: The data that you're passing contains hard line breaks (hard returns), which are breaking the functionality.
Resolution: The Web Collect feature does not support hard line breaks in submitted data. If you want to use a textarea element on your page for subscribers to submit extensive information, you must remove the hard line breaks prior to passing the data to ExactTarget, which you can do with an onSubmit function. Here's an example of this function:
function fReplace(){
var str = document.myForm.myTextArea.value;
str = str.replace(/(\r\n)/g,'');
document.myForm.myTextArea.value = str;
return false;
}
</script>
Issue: The Web Collect form on your site is not adding subscribers to your list.
Possible resolutions:
Issue: The Web Collect form on your web page is producing "Page cannot be displayed" errors.
Possible resolutions:
Issue: Your Web Collect users are experiencing error code 4.
Possible resolutions for error code 4:
Issue: Your Web Collect users are experiencing error code 10.
Possible resolutions for error code 10:
Issue: Your Web Collect users are experiencing error code 13.
Possible resolutions for error code 13:
In the following samples, the code that you will customize with your own supporting pages and attributes are shown in bold red font.
These samples illustrate the code for an account with the ExactTarget default attributes:
The following code samples are available in this document and in individual text files that you can download in a zipped file from this link: http://memberlandingpages.com/help/webcollect/WebCollectCodeSamples.zip. If you use the S4 instance, download the code samples in a zipped file from this link: http://memberlandingpages.com/help/webcollect/WebCollectCodeSamplesS4.zip.
| Sample Code | Text File |
| Subscribing to or Unsubscribing from a Single List | Subscribe-Unsubscribe_Single_List.txt |
| Subscribing to Multiple Lists | Subscribe_Multiple_Lists.txt |
| Subscribing to or Unsubscribing from Multiple Lists | Subscribe-Unsubscribe_Multiple_Lists.txt |
| Parsing Error Codes: PHP | Parsing_Error_Codes_PHP.txt |
| Parsing Error Codes: ASP | Parsing_Error_Codes_ASP.txt |
| Parsing Error Codes: Perl | Parsing_Error_Codes_Perl.txt |
Your code needs to include script that validates the email address entered by your website user. The downloadable versions of these code samples include an example of this email validation script, which is not shown here.
<form action="http://cl.exct.net/subscribe.aspx?lid=Your list ID Here" name="subscribeForm" method="post">
<input type="hidden" name="thx" value="Your thank you page here" />
<input type="hidden" name="err" value="Your error page here" />
<input type="hidden" name="usub" value="Your success unsub page here" />
<input type="hidden" name="MID" value="Your member ID here" />
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td><font face="Verdana" size="2">Name:</font></td>
<td><input type="text" name="Full Name" /></td>
</tr>
<tr>
<td><font face="Verdana" size="2">Company Name:</font></td>
<td><input type="text" name="User Defined" /></td>
</tr>
<tr>
<td><font face="Verdana" size="2">Email:</font></td>
<td><input type="text" name="Email Address" /></td>
</tr>
<tr>
<td><input type="radio" name="Email Type" value="HTML" checked="checked" />
<font face="Verdana" size="2">HTML</font>
</td>
<td>
<input type="radio" name="Email Type" value="TEXT" />
<font face="Verdana" size="2"> Text</font>
</td>
</tr>
<tr>
<td>
<input type="radio" name="SubAction" value="sub_add_update" checked="checked" />
<font face="Verdana" size="2">Subscribe</font>
</td>
<td>
<input type="radio" name="SubAction" value="unsub" />
<font face="Verdana" size="2">Unsubscribe</font>
</td>
</tr>
<tr>
<td>
<input type="submit" value="Submit" /></td>
<td align="right">
<font face="verdana" size="1" color="#4C5487">
Powered by<br> <a href="http://www.exacttarget.com">
<img src="http://www.exacttarget.com/gfx/smalllogo.gif" border="0"></a>
</font>
</td>
</tr>
</table> </form>
Your code needs to include script that validates the email address entered by your website user. The downloadable versions of these code samples include an example of this email validation script, which is not shown here.
<form action="http://cl.exct.net/subscribe.aspx" name="subscribeForm" method="post">
<input type="hidden" name="thx" value="Your thank you page here" />
<input type="hidden" name="err" value="Your error page here" />
<input type="hidden" name="SubAction" value="sub" />
<input type="hidden" name="MID" value="Your member ID here" />
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td><font face="Verdana" size="2">Name:</font></td>
<td><input type="text" name="Full Name" /></td>
</tr>
<tr>
<td><font face="Verdana" size="2">Company Name:</font></td>
<td><input type="text" name="User Defined" /></td>
</tr>
<tr>
<td><font face="Verdana" size="2">Email:</font></td>
<td><input type="text" name="Email Address" /></td>
</tr>
<tr>
<td>
<input type="radio" name="Email Type" value="HTML" checked="checked" />
<font face="Verdana" size="2">HTML</font>
</td>
<td>
<input type="radio" name="Email Type" value="TEXT" />
<font face="Verdana" size="2"> Text</font>
</td>
</tr>
<tr>
<td align=right>
<input type="checkbox" name="lid" value="First list ID here" />
</td>
<td>
<font face="Verdana" size="2">First list name here</font>
</td>
</tr>
<tr>
<td align=right>
<input type="checkbox" name="lid" value="Second list ID here" />
</td>
<td><font face="Verdana" size="2">Second list name here</font></td>
</tr>
<tr>
<td align=right>
<input type="checkbox" name="lid" value="Third list ID here" />
</td>
<td>
<font face="Verdana" size="2">Third list name here</font>
</td>
</tr>
<tr>
<td align=right>
<input type="checkbox" name="lid" value="Fourth list ID here" />
</td>
<td>
<font face="Verdana" size="2">Fourth list name here</font>
</td>
</tr>
<tr>
<td>
<input type="submit" value="Submit" />
</td>
</font>
</td>
</tr>
</table>
</form>
Your code needs to include script that validates the email address entered by your website user. The downloadable versions of these code samples include an example of this email validation script, which is not shown here.
<form action=" http://cl.exct.net/subscribe.aspx" name="subscribeForm" method="post">
<input type="hidden" name="thx" value="Your thank you page here" />
<input type="hidden" name="err" value="Your error page here" />
<input type="hidden" name="usub" value="Your success unsub page here" />
<input type="hidden" name="MID" value="Your member ID here" />
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td><font face="Verdana" size="2">Name:</font></td>
<td><input type="text" name="Full Name" /></td>
</tr>
<tr>
<td><font face="Verdana" size="2">Company Name:</font></td>
<td><input type="text" name="User Defined" /></td>
</tr>
<tr>
<td><font face="Verdana" size="2">Email:</font></td>
<td><input type="text" name="Email Address" /></td>
</tr>
<tr>
<td><font face="Verdana" size="2">Subscriber Key</font></td>
<td>input type="text" name="Subscriber Key" /></td>
</tr>
<tr>
<td>
<input type="radio" name="Email Type" value="HTML" checked="checked" />
<font face="Verdana" size="2">HTML</font>
</td>
<td>
<input type="radio" name="Email Type" value="TEXT" />
<font face="Verdana" size="2"> Text</font>
</td>
</tr>
<tr>
<td align=right>
<input type="checkbox" name="lid" value="First list ID here" />
</td>
<td>
<font face="Verdana" size="2">First list name here</font>
</td>
</tr>
<tr>
<td align=right>
<input type="checkbox" name="lid" value="Second list ID here" />
</td>
<td>
<font face="Verdana" size="2">Second list name here</font>
</td>
</tr>
<tr>
<td align=right>
<input type="checkbox" name="lid" value="Third list ID here" />
</td>
<td>
<font face="Verdana" size="2">Third list name here</font>
</td>
</tr>
<tr>
<td align=right>
<input type="checkbox" name="lid" value="Fourth list ID here" />
</td>
<td><font face="Verdana" size="2">Fourth list name here</font></td>
</tr>
<td>
<input type="radio" name="SubAction" value="sub" checked="checked" />
<font face="Verdana" size="2">Subscribe</font>
</td>
<td>
<input type="radio" name="SubAction" value="unsub" />
<font face="Verdana" size="2">Unsubscribe</font>
</td>
<tr>
<td>
<input type="submit" value="Submit" />
</td>
<td align="right">
</td>
</tr>
</table>
</form>
<?php
$errorcode = $_GET["errorcode"];
$errorcontrol = $_GET["errorControl"];
switch($errorcode) {
case "1" : $strError = "An error has occurred while attempting to save your subscriber information."; break;
case "2" : $strError = "The list provided does not exist."; break;
case "3" : $strError = "Information was not provided for a mandatory field. (".$errorcontrol.")"; break;
case "4" : $strError = "Invalid information was provided. (".$errorcontrol.")"; break;
case "5" : $strError = "Information provided is not unique. (".$errorcontrol.")"; break;
case "6" : $strError = "An error has occurred while attempting to save your subscriber information."; break;
case "7" : $strError = "An error has occurred while attempting to save your subscriber information."; break;
case "8" : $strError = "Subscriber already exists."; break;
case "9" : $strError = "An error has occurred while attempting to save your subscriber information."; break;
case "10" : $strError = "An error has occurred while attempting to save your subscriber information."; break;
case "12" : $strError = "The subscriber you are attempting to insert is on the master unsubscribe list or the global unsubscribe list."; break;
default : $strError = "Other"; break;
}
?>
<HTML><HEAD>
</HEAD>
<BODY>
<? echo 'Error: ('.$errorcode.') '.$strError; ?>
</BODY>
</HTML> <%
errorcode = Request.QueryString("errorcode")
errorcontrol = Request.QueryString("errorControl")
select case errorcode
case "1", "6", "7", "9", "10"
strError = "An error has occurred while attempting to save your subscriber information."
case "2"
strError = "The list provided does not exist."
case "3"
strError = "Information was not provided for a mandatory field. (" & errorcontrol & ")"
case "4"
strError = "Invalid information was provided. (" & errorcontrol & ")"
case "5"
strError = "Information provided is not unique. (" & errorcontrol & ")"
case "8"
strError = "You have already subscribed to this list."
case "12"
strError = "The email address is already unsubscribed."
end select
%>
<HTML><HEAD>
</HEAD>
<BODY>
<% Response.Write "Error: (" & errorcode & ") " & strError %>
</BODY>
</HTML> #!/bin/perl
use strict;
use CGI qw/:standard/;
my %strError = ( 1 => "An error has occurred while attempting to save your subscriber information.", 2 => "The list provided does not exist.", 3 => "Information was not provided for a mandatory field. (".param('errorControl').")", 4 => "Invalid information was provided. (".param('errorControl').")", 5 => "Information provided is not unique. (".param('errorControl').")", 6 => "An error has occurred while attempting to save your subscriber information.", 7 => "An error has occurred while attempting to save your subscriber information.", 8 => "You have already subscribed to this list.", 9 => "An error has occurred while attempting to save your subscriber information.", 10 => "An error has occurred while attempting to save your subscriber information.", 12 => "The email address is already unsubscribed.", );
print header, start_html, "Error: (".param('errorcode').") ".$strError{param('errorcode')} || "Invalid Entry", end_html; This page was last updated by Ryan Williams. To send Ryan direct feedback, fill out the form below: