Auto-import contacts into your getresponse campaign with pure javascript

Getresponse is email marketing software used by many online product companies. When users come to a product site then they make the purchase and pay through clickbank or any other checkout processing gateways.

So, after successful transaction you need to configure your payment gateway to redirect back user to your site with  some querystring retailed that contains customer’s name and email.

Example Click-bank after transaction url

Should be redirct to your site with buyers’ name and email[email protected]

Now we know that querystring contains,

[email protected]

So we can code a script on this orderconfirm.php page that will auto send this information to getresponse form api.

Basic Setup:-

  1. Login to your GetResponse account.
  2. Find Web Forms from Top menu.
  3. Click Create New
  4. Choose Design
  5. Then in settings, fill up Web Form Name, Turn off Confirmed opt-in (so user will be directly confirm without verification email) and choose Stay on current page
  6. Click advance and choose campaign for subscription, choose welcome message and set other criteria.
  7. Click Next and Look into Show HTML Code (turn off include css styles)
  8. Get HTML code into notepad.

Find the webform _id from your HTML code

<input type="hidden" name="webform_id" value="640305" />

and then, create and paste it in this HTML form on confirmation.php

<div style="display: none;">
	<form accept-charset="utf-8" action="" id="GRSubscribeForm" method="post" >
		<input type="hidden" id="subscriber_name" name="name" />
		<input type="hidden" id="subscriber_email" name="email" />
        <!-- copy following line from your GR HTML form code -->
		<input type="hidden" name="webform_id" value="640305" />

Include GetResponse script file in your order confirmation page.

<script src="getresponse.js" type="text/javascript"></script>

Initialize Script at bottom of your page (just before </body> tag)

    "name_param": "cname",
    "email_param": "cemail",
    "form_id": "GRSubscribeForm",
    "name_field_id": "subscriber_name",
    "email_field_id": "subscriber_email"

You can see you could customize querystring parameters cname & cemail in above options. Even specify form fields identifiers.

Script Code

var GetResponse = (function () {

    var defaults = {

        name_param: "cname",
        email_param: "cemail",

        form_id: "GRSubscribeForm",
        name_field_id: "subscriber_name",
        email_field_id: "subscriber_email"


    var __form_object;

    var __errors = [];

    var QueryString = {
        // parsing querystring
        param: function (key) {
            var qs ="?", "");
            if (qs.length != 0) {
                qs_parts = qs.split("&");
                for (k in qs_parts) {
                    qs_subparts = qs_parts[k].match(/(.+)?=(.+)?/);
                    if (typeof (qs_subparts[2]) != "undefined" && qs_subparts[1] == key) {
                        return qs_subparts[2];
                return "";
            } else {
                return "";

    var initScript = function (options) {
        // overriding defaults
        for (var opt in options) {
            if (typeof (options[opt] != "undefined")) {
                defaults[opt] = options[opt];
        return this;

    var setParams = function () {
        // exit if form id not found
        __form_object = document.getElementById(defaults.form_id);

        if (__form_object == null) {
            __errors.push("Form not found");
            __errors.push("Please check id attraibute '".concat(defaults.form_id).concat("' supplied exist on page"));
            return this;

        document.getElementById(defaults.form_id).setAttribute("target", "GRFrame");
        document.getElementById(defaults.form_id).setAttribute("method", "post");
        document.getElementById(defaults.name_field_id).setAttribute("value", QueryString.param(defaults.name_param));
        document.getElementById(defaults.email_field_id).setAttribute("value", QueryString.param(defaults.email_param));

        return this;

    var handleErrors = function () {
        if (__errors.length > 0) {
            var error_message = __errors.join("\n");
            return false;
        return true;

    var sendRequest = function () {

        if (!handleErrors()) {
            return false;

    var buildIframe = function () {

        var ifrm = document.createElement('iframe'); = "GRFrame";
        ifrm.setAttribute("name", "GRFrame");
        ifrm.setAttribute("src", "#"); = "none";


    return {
        init: initScript,
        prepare: setParams,
        send: sendRequest


Above script will,

  • Set all options supplied into init() options.
  • Then parse querystring and read cname and cemail variables
  • Fill them into GetResponse HTML form.
  • After that It’ll create hidden iframe.
  • Finally submits form into it.
  • So that these email and name will be auto-imported into your GR campaign.
  • Here, no jQuery or other library = pure javascript.
Leave a Reply

Your email address will not be published. Required fields are marked *

Previous Post

JavaScript Error Fix – TypeError: document.getElementById(…).submit is not a function

Next Post

jQuery Plugin – make jwplayer resumable for next visit and improve conversion

Related Posts