Failure in this business is unavoidable. You will hit roadblocks. You will struggle with technical aspects. You will want to give up. Plain and simple, a lot of things wont work as planned.
But, if you can keep your focus, you can win.
It's easy to give up on something quickly when it's not working. Think about how many times you've changed your online business model, chose a different niche, tried a new traffic source etc.
What would have happened if you had stayed focused at mastering what you started with?
Where would you be now?
Focus on the small wins along the way. Realize that even when something isn't working right away it is ultimately moving you towards your end goal. Even if it's a failure its a learning experience that points you in the right direction.
Keep your head down, be consistent, and keep trying!