0

I'm looking for help trying to track the affiliate ID associated with an application submitted on my wordpress site.

My application is a Zoho form imbedded in the page, so as far as I know the field inputs can't be influenced by any script on my page. The form does however collect the referring link. So I can see my application URL in my submitted form data.

http://www.example.com/apply-now/

If i could add the referral ID:

?wpam-id=1

from my affiliate link:

http://www.example.com/?wpam_id=1

as a parameter to the application page so it looked like this:

http://www.example.com/apply-now/?wpam_id=1

it could be tracked perfectly. I installed the PHP everywhere plugin: https://wordpress.org/plugins/php-everywhere/ and used some PHP in my application page to pull the ID from the cookie and show it on the page,

<?php

$aff_id = $_COOKIE['wpam_id'];
echo "affiliate ID: ". $aff_id;

?>

then tried get it into the URL with no avail using

<?php

$aff_id = $_COOKIE['wpam_id'];
$url = "ref-id?" $aff_id;
header(string: 'location: ' . $url);

?>

Is there a mistake in my code or for this to work do I need to put it into one of the other .php files instead of the page itself? If so which one?

Would it be easier to just redirect to the new URL somehow?

Thank you for your help in advance.

Bhargav Rao
  • 50,140
  • 28
  • 121
  • 140
Timosea
  • 1
  • 1
  • I'm not familiar with Zoho specifically, but is there a particular reason you don't think this could be accomplished with jQuery, which WordPress includes? – Michael W. Jun 14 '18 at 22:57
  • I need Zapier integration to transfer the application data in into my CRM, I don't think jQuery is integrated? – Timosea Jun 14 '18 at 23:04
  • I mean using jQuery to alter the form after it has loaded to include the affiliate information. Or am I misunderstanding your problem? – Michael W. Jun 14 '18 at 23:08
  • I'm not very fluent at web building, I'm not exactly sure how to go about that to know if it would or not? The Zoho form is self hosted and is just imbedded in my sight. If you think that would be possible I'm up for trying it! – Timosea Jun 14 '18 at 23:21
  • Show me the line in the form that displays the URL. – Michael W. Jun 15 '18 at 15:18
  • The form is imbedded like an iframe function: [link] [zohoForms src=https://forms.zohopublic.com/mybis/form/application/formperma/fSuCbeOf5dC71VvhM_JUG3OZDhUrqPOPVSxvnuXbmPA width=100% height=600px/] the line would be Ref_id, I was trying out what you were mentioning and it seemed like I could do it with zoho creator but not this form... – Timosea Jun 16 '18 at 16:06
  • Oof, an iframe. Unless zoho specifically allows you to do this with a cross-domain policy, *you cannot alter the contents of an iframe.* See generally: https://stackoverflow.com/questions/11658011/cannot-modify-content-of-iframe-what-is-wrong – Michael W. Jun 17 '18 at 18:16

1 Answers1

0

you can try the following:

<?php

$aff_id = $_COOKIE['wpam_id'];
$url = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]?".$aff_id;
header(string: 'location: ' . $url);

?>

this will get the current URL on post/get and then append the aff_id and redirect.

Tommys
  • 121
  • 8