TeamRaiser - Building a new url based on the donation form URL parameters

Options
Hi all,


Convoluted question here, so I'll try my best to explain what I am trying to do...


Some background - Here at the foundation, we do not receipt gifts from Organizations, we give them "Business Acknowledgement Letters". Because of this, we have to always have 2 of every donation campaign form; one for orgs, one for Individuals.


In TeamRaiser, for an event, you can only attach one donation form to a TeamRaiser Event, but I need to be able to dynamically create a URL on the attached donation form (which is set up for individual donations) so that if the donor is donating on behalf of a business, they can click a link at the top which points to the org form, but with the required url parameters needed to ensure that the donation is directed to the correct proxy_type, proxy_id and fr_id.


Has anyone done anything like this before? Not sure if I'm even being clear.


Thanks,

ali
Tagged:

Comments

  • As long as you pass the FR_ID, PROXY_TYPE, and PROXY_ID to the second donation form, it'll work, even though the form isn't the one associated with the TeamRaiser.
  • But I don't know how to get that information out. I've found some jQuery snippets but I can't seem to pull that information from the linked url form in order to build out the string correctly.


     
  • NM, I got it! Just had to add some jquery and build it out on the fly.


    Once I've tested I can share in case anyone else is interested.
  • I'm pretty sure the proxy_type is always 20 and the proxy_id is the ID of the event, team or participant that gets the credit, so you should be able to build the url with S-Tags.


    Edit: and if this link appears on the regular donation form, there's an s-tag (S334) to pull query string params.



    https://secure#.convio.net/ABC/site/Donation2?df_id=12345&FR_ID=[[S334:FR_ID]]&mfc_pref=T&PROXY_ID=[[S334:PROXY_ID]]&PROXY_TYPE=20&[[S334:FR_ID]].donation=form1
  • The proxy_type changes depending on if its a participant, team or directly to the event


    20 is participant

    21 is event

    22 is team


    I didn't even consider using s-tags, I'm now annoyed with myself...
  • Actually, jQuery is the right solution. Using S334 for this sort of thing to pull information out of the URL is unreliable, since there are a number of cases when the URL changes to drop all query strings (e.g. when an error is encountered on submit).
  • Ugh, right. I hate that. But where would jQuery get these values if not from the QString?


    What about sticking them in a session variable, and then build the URL from that, or just store the whole URL? Something like...


    [[? x[[S334:FR_ID]]x:: xx :: :: [[U0:altUrl=https://secure#.convio.net/ABC/site/Donation2?df_id=12345&FR_ID=[[S334:FR_ID]]&mfc_pref=T&PROXY_ID=[[S334:PROXY_ID]]&PROXY_TYPE=20&[[S334:FR_ID]].donation=form1]]


    / Not sure about that U0 tag and all the = signs in the full url.
  • But where would jQuery get these values if not from the QString?


    Hidden inputs. Dumb me.

    <input type="hidden" name="df_id" id="df_id" value="11041" />

    <input type="hidden" name="FR_ID" id="FR_ID" value="1620" />
    <input type="hidden" name="mfc_pref" id="mfc_pref" value="T" />
    <input type="hidden" name="PROXY_ID" id="PROXY_ID" value="1620" />
    <input type="hidden" name="PROXY_TYPE" id="PROXY_TYPE" value="21" />
  • I "borrowed" the function. Then called the function to build the url, and then finally dropped into a div tag.


    I don't know if this is "correct" from a web standard perspective, but it works...I should probably add something in the function to account for null values, but I didn't


    <script type="text/javascript">// <![CDATA[


    jQuery(document).ready(function ($) {


    //parse url to get the paramters

    function getParameterByName(name) {

        var match = RegExp('[?&]' + name + '=([^&]*)')

                        .exec(window.location.search);

        return match && decodeURIComponent(match[1].replace(/\\+/g, ' '));


    }


    //build out the url by calling the getParamterByName function to fill in the needed bits. (note, if you use this

    //elsewhere or to another form, you have to update the df_id manually...

    var orgURL = '<a href="https://secure2.convio.net/srhcf/site/Donation2?df_id=2363&mfc_pref=T&2363.donation=form1&PROXY_ID=' + (getParameterByName('PROXY_ID')) +'&PROXY_TYPE='+(getParameterByName('PROXY_TYPE'))+ '&FR_ID='+(getParameterByName('FR_ID'))+'">Click here to make this donation on behalf of an Organization</a>';


    //put the new url where you want it (see next HTML caption area)

    document.getElementById('OrgURL').innerHTML=orgURL;

    })



    // ]]></script>
  • This solution is using the querystring variables, just like my S-Tag idea did. But as Noah pointed out, if there is a validation error the page will postback and all those variables in the URL disappear - and your url will be broken.


    However, the donation form itself has those values stored in hidden inputs. You can safely grab those instead.


    var orgFormId = '2363';

    var orgURL =

    '<a href="https://secure2.convio.net/srhcf/site/Donation2' +

    '?df_id=' + orgFormId +

    '&mfc_pref='+ $('#mfc_pref').value() +

    '&' + orgFormId + '.donation=form1' +

    '&PROXY_ID=' + $('#PROXY_ID').value() +

    '&PROXY_TYPE=' + $('#PROXY_TYPE').value() +

    '&FR_ID=' + $('#FR_ID').value() +

    '">Click here to make this donation on behalf of an Organization</a>';

     
  • Thanks, I'll update it now. This will also make it easier moving forward if someone else has to take over the maintenance of these pages.


    Ali
  • Anyone know if there's an S-Tag that would return the current form's df_id? I'm thinking about the canonical tag here, where JS isn't going to work.

    EDIT2: Just found something that could be promising! I didn't realize that there's an [[S42:0:form-ID]], so there's half the equation. For the org ID, we could do something like [[?xx::x[[S334:df_id]]x::::[[U0:dfID=[[S334:df_id]]]]]] to capture the ID for situations where the form is submitted in error. Could even add some JS to rewrite the URL (for cases where the user submits the form in error, then copies the URL and sends it to someone, such as calling us because they couldn't figure out the problem).

    Would that make it reliable enough to grab the ID without resorting to JS, or are there still other situations where the form would load the first time without the right URL variable?


    One other thought; if it's already known which donation forms go with which teamraiser, you could do set up a reusable that basically makes a pseudo-table matching different df_ids to fr_ids. Something like...

     
    [[U0:corpFRID=[[E130:   [[S80:trID]]

          1234      5678      replaceall

          2345      6789      replaceall

          3456      7890      replaceall

    ]]

    [[?x[[U80:corpFRID]]x::x[[S80:trID]]x::[[E42:[[S80:trID]]:form-ID]]::]]



    ...where the first number is the trID and the second is the corporate form's ID.


    It'll grep through the table and return whatever matches. If no match exists, that second statement will set the form to the event ID as a fallback (or you could make it anything you want). Also assuming in those that you've captured the teamraiser ID into a trID variable. If not, you'd swap those out with [[S42:0:fr-id]].
  • Hi Jeremy,


    Nice tinkering, but I think the Javascript approach (those steps discussed above) would be a much stable approach compared to S-tag, due to 
    • truncated URL behavior on LO Donation form esp. when one did not fill up the form completely and the form ask you to rectify the thing at which points the page seems to refresh itself no longer without the DF_ID on the URL parameter -- rendering the S334 unusable
    • What if a donation is not a teamraiser based donation in which the S42:0 won't be applicable.
    • Now with session variable storing through that U0, that is a step forward; however there is another loophole that potentially could mess that thing which is "what if someone opens up different donation forms as new tabs within a single browser where those forms happen to have that same session variable storing mechanism" -- that would turn into value override to whatever donation form opens up last.
    • We got to remember that Javascript is a client-end while S-tag is server-side when it comes to writing/rewriting values or communicating back-and-forth (i.e JS can't dynamically re-assign S-tag session variable initial values post page load)
    With the new donation forms now seems to hold the stored DFID, FRID through the hidden inputs, I think that should resolve the above dillema and would now allow Javascript to handle that as alternative without going the extra miles


     
  • Good timing on the questoin and the proposed solution seems to have worked for me!

    Thansk for all your help my Luminate Peoples!
  • Hi all,


    Just wanted to say that I had to make a small change to Brians code to get it to work for me.


    I had to change the .value to .val


    Thanks!

    ali

Categories