Nextjs and Grow
CompletedI tried to connect grow via the below <script> tag. Grow Dashboard says that it's connected but my concern is → Since I am using single page application, the script just executes only once. Can this result into less page view count by Grow? (PS: I have used useEffect approach as well but still script does not fire when visiting new page).
This api (URL: https://api.grow.me/sites/bfa9c25b-7ecd-4f49-b8de-ee4aa3fc723f/page?url=https%3A%2F%2Fwww.nailyourinterview.org%2F) is only called once when someone visits my website. Notice my url, even if I visit different page, it still shows same.
Also, the heart icon, which should appear is not appearing.
Website : https://nailyourinterview.org
import Script from "next/script";
<Script
id="grow-script"
strategy="beforeInteractive"
data-grow-initializer=""
dangerouslySetInnerHTML={{
__html: `
!(function () {
window.growMe || ((window.growMe = function (e) { window.growMe._.push(e); }), (window.growMe._ = []));
var e = document.createElement("script");
e.type = "text/javascript";
e.src = "https://faves.grow.me/main.js";
e.defer = true;
e.setAttribute("data-grow-faves-site-id", "${process.env.NEXT_PUBLIC_GROW_ID}");
var t = document.getElementsByTagName("script")[0];
t.parentNode.insertBefore(e, t);
})();
`,
}}
/>-
Official comment
Hi Shubh Patel ! We recommend loading the Grow script as it is in your dashboard without any additional attributes, since it can lead to unexpected issues with analytics tracking/general functionality. You can load it through a hook, but it needs to be the script from the dashboard without anything additional added to it. We have other SPA sites on Journey, so loading the script normally should resolve any potential tracking issues.
It also looks like your site is missing language metadata, which can cause issues with the Grow widget. You'll want to add language metadata when you can and that could resolve the problem with the widget. If it doesn't though and you're still not seeing the widget, you'll want to write in to grow@mediavine.com for further assistance!
Journey is Self Supported
Please sign in to leave a comment.
Comments
1 comment