I just signed up with an affiliate network and they want me to include something like this on my order confirmation pages:
<script type="text/javascript" src="//www.affiliate-monkey.com/js/track.js?eventid=1234&pid=5678&reference=XYZ_123&amount=123.45"></script>
<noscript>
<img src="//www.affiliate-monkey.com/event.php?pid=5678&eventid=1234&reference=XYZ_123&amount=123.45" border="0" width="1" height="1">
</noscript>
In particular, they want me to pass the customer reference
and the purchase amount
.
Is there some sort of Best Practice on how to integrate this into a Rails application?
This is how I thought it might work:
class SubscriptionsController < ApplicationController
...
def create
@subscription = CreateSubscription.call(@plan, current_user)
if @subscription.errors.blank?
flash[:success] = "You changed your plan!", :plan => @plan.name
redirect_to subscription_path(:reference => current_user.reference_number, :amount => @plan.amount)
else
render :new
end
end
...
end
However, I dislike the fact that users can see the reference
and amount
parameters in the URL. I don't want them to get tampered with.
What might be a better way to do this?