How to Dynamically pass email address to embedded custom form

MichaelM127
Frequent Participant

How to Dynamically pass email address to embedded custom form

How can I dynamically pass email address from signup block to embedded custom form on another page. For example a customer sees our signup for newsletter block on our homepage and fills in his email address and hits submit. Once the new page loads his email address is already in our form so he doesn't have to type it a second time on the newly loaded signup form page.

 

FYI we are using the API and CCSFG.

 

Thanks in advance for your help.

7 REPLIES 7
Shannon_W
Employee

Hi,

 

I really wouldn't recommend using the CCSFG if your integration is intended to be used for more than about a year.  We don't have a firm date yet, but the V1 API that the CCSFG is built on, and basic authentication, will be deprecated in about a year.

 

I'd recommend downloading the newer php-sdk here and using the addUpdate file in the examples folder as a starting point.  You'll want to pass in the email address as a variable into the example form if the user will be putting that in before they get to the form.

 

Best Regards,

Shannon W.

API Support Specialist

MichaelM127
Frequent Participant

Thanks Shannon I will dive into that then.

MichaelM127
Frequent Participant

Shannon or anyone else who can help I am going to have to use the CCSFG for now until I can get my head around how to use the PHP inside of Magento. Can you please tell me is it possible to dynamically pass the email address onto the CCSFG form as you mentioned via a variable so the user doesnt have to enter it twice?

While CCFSG does not support this by default, you could easily customize it to add that functionality if you are familiar with PHP.  If your signup script is hosted on http://example.com/signup.php, for example, you would simply need to modify the ccfsg script to look for query parameters before displaying the form.  Then you could add a query param to the URL that would look something like this:

 

http://example.com/signup.php?email=someemail@example.com

 

The form could then look at the query params passed in prior to displaying and pre-populate the email field with the query parameter passed in.  If you do this request as a GET, you can see documentation for how you could parse these values here: http://php.net/manual/en/reserved.variables.get.php.  The same is true for a POST to the form here: http://www.php.net/manual/en/reserved.variables.post.php 

 

Hope this helps!

Dave Berard
Senior Product Manager, Constant Contact
MichaelM127
Frequent Participant

Thanks Dave im a PHP rookie, but can usually figure it out. Heres the issue im having. I have taken the entire CCSFG master folder and placed it in our directory and the signup form is working great, but when using the subscribe block to send users to the embedded form on another page it doesnt reference the PHP file its action is the page destination where the form lives. In addition the CCSFG doesnt have a signup.php file as far as I can tell I am using index.php on the actually form. Heres the code im using for the signup block(I have removed my website name for this example):

 

<div  style="background-color:#333; border: 0px solid #00adee; padding:8px; margin-bottom: 2px;"><!-- BEGIN: Constant Contact Stylish Email Newsletter Form -->
<div style="margin-left:10px;"><form style="margin-bottom: 3;" action="http://www.example.com/subscriptions" method="post"> <font style="font-family: Verdana,Geneva,Arial,Helvetica,sans-serif; font-weight:bold; font-size: 16px; color:#00adee">Get Promos and News</font> <br><input style="margin: 5px; font-family: Verdana,Geneva,Arial,Helvetica,sans-serif; font-size: 16px; border: 0px solid #00adee;" name="ea" size="20" type="text" /><input src="{{skin url="images/btn_join.png"}} " type="image" value="Sign me up" /> <input name="EmailAddress" type="hidden" value="EmailAddress" /></form> <!-- END: Constant Contact Stylish Email Newsletter Form --> <br /><div style="font-family: Verdana,Geneva,Arial,Helvetica,sans-serif; font-size: 14px; color:#ffffff;">Sign Up For Weekly Specials, Tech Tips, Product Features and Product <br /> Reviews. </div>     </div></div>

 

Thanks in advance for your help.

 

Hello,

 

Based on what you have, when you submit that form, it will load the index page at http://www.example.com/subscriptions and you will have the EmailAddress variable available on the POST. Assuming that this index page is your signup form which submits to CCSFG, you can modify the email address input field on that form so that the default value is gathered from your POST through PHP.

 

However, if it's not loading the right page or the information isn't getting sent properly, you can change the form on the front page to reference the php file containing your signup form directly.

 

If you're still struggling, you can either reply here, or you can email us at webservices@constantcontact.com so that information such as your website can be shared privately. Whichever works best, we're happy to help you get this running!

 

Sincerely,

Elijah G.

API Support Specialist

Elijah G.
API Support Engineer
MichaelM127
Frequent Participant

Thanks I will email you privately for assistance. Thanks!

Developer Portal

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

Visit Page