Home / Admin / om-nextjs.js
Duplicate Snippet

Embed Snippet on Your Site

om-nextjs.js

Code Preview
js
import { useEffect } from 'react';
import { useRouter } from 'next/router';
const OptinMonsterEmbed = () => {
	const router = useRouter()
	  useEffect(() => {
	    const handleRouteChange = (url, { shallow }) => {
		if (window.om5678_1234) {
	            window.om5678_1234.reset();
	        }
	    }
	 
	    router.events.on('routeChangeComplete', handleRouteChange);
	    // If the component is unmounted, unsubscribe
	    // from the event with the `off` method:
	    return () => {
	      router.events.off('routeChangeComplete', handleRouteChange)
	    }
	  }, [router]);
	return `<script>(function(d,u,ac){var s=d.createElement('script');s.type='text/javascript';s.src='https://a.omappapi.com/app/js/api.min.js';s.async=true;s.dataset.user=u;s.dataset.account=ac;d.getElementsByTagName('head')[0].appendChild(s);})(document,1234,5678);</script>`;
}
export { OptinMonsterEmbed };

Comments

Add a Comment