- 16 Nov 2023
- 2 Minutes to read
- DarkLight
Cross Domain Implementation
- Updated on 16 Nov 2023
- 2 Minutes to read
- DarkLight
Summary
This article provides instructions on how to persist a LeadiD token from one domain to another. This implementation should be used only in the event that a single inquiry funnel spans multiple domains.
Option 1
Using the Standard ‘leadid_token’ field
The standard steps within our Getting Started Guide explain how to create a hidden form field with the id attribute “leadid_token” and how to have this form field be automatically populated with a new token. This form field can also work in the opposite direction; supplying an existing token to the script to reuse it, instead of creating a new token.
Instructions
- Save the Jornaya LeadiD token to a variable when the form is posted
- Using that variable, pass the LeadiD token to the new domain in the URL
- Populate the leadid_token hidden input on the new domain, using the value passed from the URL
Example (PHP):
Assuming the form post sends the token through with the form name “universal_leadid”, the PHP code to process read in the value when processing the form post is:
$leadidToken = $_POST[‘universal_leadid’];
Next, build the redirect to another domain in PHP, since you need to pass the token in the URL and do not know it ahead of time:
header(“Location: http://www.somesite.com/thank-you.php?
Finally, on the new domain, populate the token from the URL data in the HTML page:
</form>
…
<input type="hidden" name="universal_leadid" id="leadid_token" value="<?
php echo $_GET['token']; ?>"
…
</body>
Option 2
Using the Global Callback to pass the Token in the URL
The Jornaya Callback function allows the site operator to designate a function where the LeadiD will be returned to instead of it being returned to the standard hidden input field with attribute of 'leadid_token'. The site operator can implement logic within the function to include the LeadiD value in the URL when a form is posted.
Instructions:
- Update the Jornaya campaign code snippet to include the name of a global javascript function you will define (see detailed instructions here for implementing a callback function)
- Write logic into the javascript function you defined to include the LeadiD in the URL on form post
Example (jQuery):
Make sure there is a global function defined with the correct name. The LeadiD token value will be passed as the first argument. Here is an example that will update a form "action" to include the LeadiD token in the URL:
function insertToken(token){
//Get the prior action and add the token to the end
var action = $('#signup-form').attr('action') + '?token=' + token
$('#signup-form').attr('action', action);
}
Once implemented, follow the steps in the Campaign Implementation Self Test to verify the implementation is working as expected.