Need form's source code to trigger tracking URL first

mpbiz

New member
Apr 29, 2010
2,825
57
0
I have a piece of source code on my page that looks like this:

<script src="http://formgenerator.com/s/?req=generate_form&lid=595959&l_create_paid=1&l_paid_image=http%3A//buttongenerator.com/images/submitbutton.png"></script>

Basically on my page it embeds/creates a simple form and also the actual button that the user clicks on to submit their form information.

Anyways, I need to be able to keep using the source code above, but I need to make a small tweak. When someone fills out that form and clicks the form submit button, I need it to trigger/submit to my tracking URL first.

But I don't know how to add this extra URL into that source code and make everything still work.

Any of you guys know how to do something like this?
 


Use javascript (jquery makes it easy), remove the form button (or disable and hide it), place your own in the place. Hook the button on click. Fire off your tracking url, then submit the form.

Boom.
 
  • Like
Reactions: mpbiz
Bump.

Hired someone to do this for me and he's saying it wont work because...

"The source code is an iframe and we cannot use javascript or jquery because they would be on a separate domain."

Iframe (source code in OP) is from formgenerator.com

Javascript/jquery is on my self hosted landing page mysite123.com

Is my freelancer wrong or right? Any ideas on another way to do this successfully?

Thanks for the help bros.
 
I can't load the FormGenerator site to see what is being generated at the moment, but I may suggest you do something like this:
a) rebuild the HTML of the form and host it on your site
b) change the HTML form to post to your site directly
c) in the form handler on your site, log the occurance (or whatever tracking logic you want) and cURL post the information submitted by the visitor to the form at FormGenerator.com

Sample code:
Code:
$post_data = array(
        'whatever' => $_POST['whatever'],
        'posted' => '...',
        'values' => '...',
        'you' => '...',
        'have' => '...',
);

$ch = curl_init("http://formgerator.com/whatever-the-post-address-is.php");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_arr);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
 
  • Like
Reactions: mpbiz
I can't load the FormGenerator site to see what is being generated at the moment, but I may suggest you do something like this:
a) rebuild the HTML of the form and host it on your site
b) change the HTML form to post to your site directly
c) in the form handler on your site, log the occurance (or whatever tracking logic you want) and cURL post the information submitted by the visitor to the form at FormGenerator.com

Sample code:
Code:
$post_data = array(
        'whatever' => $_POST['whatever'],
        'posted' => '...',
        'values' => '...',
        'you' => '...',
        'have' => '...',
);

$ch = curl_init("http://formgerator.com/whatever-the-post-address-is.php");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_arr);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);

Ended up just cloning the form and submitting data that way but thanks for the help.
 
A simple hack could be using something like cross-document messaging: Learning from XAuth: Cross-domain localStorage | NCZOnline which is free source and 100% javascript.

Server Code: https://github.com/xauth/xauth/blob/master/src/server.js
API Library: https://github.com/xauth/xauth/blob/master/src/xauth.js

Normally you can't access localstorage data from other domains but you can use ^^ to get around that so you can save the data clientside and access it from another domain. My kindle and phone use localstorage no prob.