add coupon tracking and fix compatibility PHP issues