There are tools, also open source, which give you a basic functionality to do that for free. If you'd like something more advanced with optimizations (e.g. limiting any negative impacts) and KPIs you'll need to sign-up for a service that does it.
Cart Defender - slash cart abandonment and drive sales with unlimited intelligent conversion popups. Forget A/B tests because Cart Defender optimizes itself automatically. Web Summit 2016