Changeset 2083912
- Timestamp:
- 05/08/2019 06:18:28 PM (7 years ago)
- Location:
- really-simple-affiliate-program/trunk
- Files:
-
- 3 edited
-
js/rsap_main.js (modified) (3 diffs)
-
readme.txt (modified) (2 diffs)
-
really-simple-affiliate-program.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
really-simple-affiliate-program/trunk/js/rsap_main.js
r2047630 r2083912 1 // On page load, check for rfr parameter in URL and store in cookie if present, 2 // that way the user can browse the website and come back to the form while 3 // the referrer affiliate is still tracked 4 5 jQuery(document).ready(function (e) { 6 var url_string = window.location.href; 7 var url = new URL(url_string); 8 var referrerCode = url.searchParams.get("rfr"); 9 10 if (referrerCode == '' || referrerCode == null) { 11 // Do nothing since no referrer code is present in the URL 12 } else { 13 // Store the affiliate code for 30 days 14 rsapCreateCookie('rsap_referrer', referrerCode, 30); 15 //console.log(rsapReadCookie('rsap_referrer')); 16 } 17 18 // Populate gravity forms hidden field if present 19 jQuery('input[type="hidden"][value="RSAP"]').val(rsapReadCookie('rsap_referrer')); 20 }); 21 1 22 // Create new affiliate 2 23 jQuery('.rsap_affiliate_form_holder form').submit(function (e) { … … 33 54 //console.log(referrerCode); 34 55 56 // Override referrerCode with the cookie in case the URL token is no longer present 57 referrerCode = rsapReadCookie('rsap_referrer'); 58 35 59 36 60 … … 52 76 }); 53 77 }); 78 79 // The following code is from https://www.quirksmode.org/js/cookies.html 80 81 function rsapCreateCookie(name, value, days) { 82 if (days) { 83 var date = new Date(); 84 date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); 85 var expires = "; expires=" + date.toGMTString(); 86 } else var expires = ""; 87 document.cookie = name + "=" + value + expires + "; path=/"; 88 } 89 90 function rsapReadCookie(name) { 91 var nameEQ = name + "="; 92 var ca = document.cookie.split(';'); 93 for (var i = 0; i < ca.length; i++) { 94 var c = ca[i]; 95 while (c.charAt(0) == ' ') c = c.substring(1, c.length); 96 if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length); 97 } 98 return null; 99 } 100 101 function rsapEraseCookie(name) { 102 createCookie(name, "", -1); 103 } 104 105 // End code from https://www.quirksmode.org/ -
really-simple-affiliate-program/trunk/readme.txt
r2067450 r2083912 3 3 Tags: affiliate, program, referral 4 4 Requires at least: 4.0 5 Tested up to: 5.1 5 Tested up to: 5.1.1 6 6 Stable tag: trunk 7 7 License: GPLv2 or later … … 23 23 24 24 == Changelog == 25 26 = 2.1 = 27 28 * IMPROVEMENT: Added cookie-based referrer tracking so that the customer can browse the site and come back to the conversion form. 25 29 26 30 = 2.0 = -
really-simple-affiliate-program/trunk/really-simple-affiliate-program.php
r2067450 r2083912 4 4 Plugin Name: Really Simple Affiliate Program 5 5 Description: Allows you create an easy affiliate signup page on your website, which people can use to get an affiliate code to share your product or service with others. Using that affiliate code and link, you will see whenever that person brings in a referral from the dashboard build right into Wordpress. 6 Version: 2. 06 Version: 2.1 7 7 Author: Maplespace Inc. 8 8 Author URI: https://maplespaceinc.com/ … … 195 195 <h2>For Outputting the Affiliate Code in a Gravity Forms Form</h2> 196 196 <ol> 197 <li>In the Gravity Forms form editor, add a ' Single Line Text' input field.</li>197 <li>In the Gravity Forms form editor, add a 'Hidden' input field.</li> 198 198 <li>Open that new field, and title it 'Affiliate Code'.</li> 199 <li>Under the 'Advanced' tab of that new field, check the box titled 'Allow field to be populated dynamically'.</li> 200 <li>In the parameter name, type 'rfr' without the single quotes.</li> 199 <li>Under the 'Advanced' tab of that new field, set the default value to "RSAP" without the quotes.</li> 201 200 <li>Click 'Update' on the form to save your changes.</li> 202 <li>Now when the form is opened using someone's affiliate link, that field will automatically be filled with it. You can test this by adding <code>?rfr=4050</code> to the end of the form page's URL.</li>201 <li>Now when the form is submitted within 30 days after an affiliate linked was clicked leading to your site, you will see that code in the email you receive. You can test this by adding <code>?rfr=4050</code> to the end of the form page's URL.</li> 203 202 <li>Note that you may need to adjust your email template so that this new field is included when it is sent to you for tracking purposes.</li> 204 203 </ol> … … 566 565 wp_enqueue_script( 'rsap-main-js', plugins_url( 'js/rsap_main.js', __FILE__ ), array('jquery'), false, true ); 567 566 wp_localize_script('rsap-main-js', 'rsap_script_vars', array( 568 'conversion_form_wrapper_id' => get_option('rsap_option_conversion_form_wrapper_id') 567 'conversion_form_wrapper_id' => get_option('rsap_option_conversion_form_wrapper_id'), 568 'url_rfr_parameter' => $_GET['rfr'] 569 569 ) 570 570 );
Note: See TracChangeset
for help on using the changeset viewer.