Plugin Directory

Changeset 2083912


Ignore:
Timestamp:
05/08/2019 06:18:28 PM (7 years ago)
Author:
likebuttonsoftware
Message:

Version 2.1

Location:
really-simple-affiliate-program/trunk
Files:
3 edited

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
     5jQuery(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
    122// Create new affiliate
    223jQuery('.rsap_affiliate_form_holder form').submit(function (e) {
     
    3354    //console.log(referrerCode);
    3455
     56    // Override referrerCode with the cookie in case the URL token is no longer present
     57    referrerCode = rsapReadCookie('rsap_referrer');
     58
    3559
    3660
     
    5276    });
    5377});
     78
     79// The following code is from https://www.quirksmode.org/js/cookies.html
     80
     81function 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
     90function 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
     101function 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  
    33Tags: affiliate, program, referral
    44Requires at least: 4.0
    5 Tested up to: 5.1
     5Tested up to: 5.1.1
    66Stable tag: trunk
    77License: GPLv2 or later
     
    2323
    2424== 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.
    2529
    2630= 2.0 =
  • really-simple-affiliate-program/trunk/really-simple-affiliate-program.php

    r2067450 r2083912  
    44Plugin Name: Really Simple Affiliate Program
    55Description: 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.0
     6Version: 2.1
    77Author: Maplespace Inc.
    88Author URI: https://maplespaceinc.com/
     
    195195 <h2>For Outputting the Affiliate Code in a Gravity Forms Form</h2>
    196196 <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>
    198198 <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>
    201200 <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>
    203202 <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>
    204203 </ol>
     
    566565    wp_enqueue_script( 'rsap-main-js', plugins_url( 'js/rsap_main.js', __FILE__ ), array('jquery'), false, true );
    567566    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']
    569569        )
    570570    );
Note: See TracChangeset for help on using the changeset viewer.