You can create a module to get the parameter from the URL and apply a coupon code/discount rule programatically. Here you have a guide.
Another wy is to save the code from the url in session/cookies and use an observer to apply the discount once in checkout. This is explained here.here.