# Unable to install a container into NextJS Project

**URL:** <https://community.piwik.pro/t/unable-to-install-a-container-into-nextjs-project/616>\
**Category:** API & integrations\
**Created:** [April 22, 2022, 9:46am UTC](https://community.piwik.pro/t/unable-to-install-a-container-into-nextjs-project/616 "2022-04-22T09:46:54Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![kentran](https://avatars.discourse-cdn.com/v4/letter/k/958977/32.png) [@kentran](https://community.piwik.pro/u/kentran)\
**Post date:** [April 22, 2022, 9:46am UTC](https://community.piwik.pro/t/unable-to-install-a-container-into-nextjs-project/616/1 "2022-04-22T09:46:54Z")

</div>

I am trying to integrate Piwik Pro into my NextJS project but received the \*\* **TypeError: (intermediate value)(…) is not a function**\*\* error.

 ![error](https://europe1.discourse-cdn.com/flex005/uploads/piwikpro/original/1X/ad33d6cc360522c9d9613f684d68f8d52e914b9e.png)

I included the installation script with [NextJS Script tag](https://nextjs.org/docs/api-reference/next/script) as follows

```auto
<Script
            dangerouslySetInnerHTML={{
                __html: `              
                    (function(window, document, dataLayerName, id) {
                      window[dataLayerName]=window[dataLayerName]||[],window[dataLayerName].push({start:(new Date).getTime(),event:"stg.start"});var scripts=document.getElementsByTagName('script')[0],tags=document.createElement('script');
                      function stgCreateCookie(a,b,c){var d="";if(c){var e=new Date;e.setTime(e.getTime()+24*c*60*60*1e3),d="; expires="+e.toUTCString()}document.cookie=a+"="+b+d+"; path=/"}
                      var isStgDebug=(window.location.href.match("stg_debug")||document.cookie.match("stg_debug"))&&!window.location.href.match("stg_disable_debug");stgCreateCookie("stg_debug",isStgDebug?1:"",isStgDebug?14:-1);
                      var qP=[];dataLayerName!=="dataLayer"&&qP.push("data_layer_name="+dataLayerName),isStgDebug&&qP.push("stg_debug");var qPString=qP.length>0?("?"+qP.join("&")):"";
                      tags.async=!0,tags.src="https://kentran.containers.piwik.pro/"+id+".js"+qPString,scripts.parentNode.insertBefore(tags,scripts);
                      !function(a,n,i){a[n]=a[n]||{};for(var c=0;c<i.length;c++)!function(i){a[n][i]=a[n][i]||{},a[n][i].api=a[n][i].api||function(){var a=[].slice.call(arguments,0);"string"==typeof a[0]&&window[dataLayerName].push({event:n+"."+i+":"+a[0],parameters:[].slice.call(arguments,1)})}}(i[c])}(window,"ppms",["tm","cm"]);
                    })(window, document, 'dataLayer', '106aa643-d79c-4201-b52f-ed2f355af107');
                `
            }}
        />   

```

Please help to check!

---

<div class="post-metadata">

**Author:** ![Piotrek](https://dub1.discourse-cdn.com/flex005/user_avatar/community.piwik.pro/piotrek/32/160_2.png) [@Piotrek](https://community.piwik.pro/u/Piotrek)\
**Post date:** [April 22, 2022, 12:30pm UTC](https://community.piwik.pro/t/unable-to-install-a-container-into-nextjs-project/616/2 "2022-04-22T12:30:51Z")

</div>

Hello @kentran,

We previously saw that in cases like this, following [this general guide](https://github.com/vercel/next.js/tree/canary/examples/with-google-analytics) for implementing analytics (like GA) helps.

Also, could you try following some of the ideas and tips provided in [this thread](https://community.piwik.pro/t/error-with-nextjs-setup/602/2)?

Let us know if that helps. We will also create a feature request for us to provide some dedicated documentation for NextJS in the near future.

---

<div class="post-metadata">

**Author:** ![kentran](https://avatars.discourse-cdn.com/v4/letter/k/958977/32.png) [@kentran](https://community.piwik.pro/u/kentran)\
**Post date:** [April 25, 2022, 1:57am UTC](https://community.piwik.pro/t/unable-to-install-a-container-into-nextjs-project/616/3 "2022-04-25T01:57:59Z")

</div>

Dear @Piotrek,

Thanks for your response.  
I went through the guide and thread but unfortunately, it couldn’t help to resolve the issue.  
The reason is this error came from the script that loaded from your backend, not from the configure container tag

 ![1650851824(1)](https://europe1.discourse-cdn.com/flex005/uploads/piwikpro/original/1X/ab3a29b9a869a98fbec30a94895c589992ffdf2a.png)

---

<div class="post-metadata">

**Author:** ![leevi978](https://dub1.discourse-cdn.com/flex005/user_avatar/community.piwik.pro/leevi978/32/364_2.png) [@leevi978](https://community.piwik.pro/u/leevi978)\
**Post date:** [April 30, 2022, 7:47pm UTC](https://community.piwik.pro/t/unable-to-install-a-container-into-nextjs-project/616/4 "2022-04-30T19:47:06Z")

</div>

I have this exact same issue when I try to add this script tag in my Gatsby project. Maybe Piwik-pro should work on a guide for using the tool with server-side rendered pages? @Piotrek

---

<div class="post-metadata">

**Author:** ![Pawel](https://dub1.discourse-cdn.com/flex005/user_avatar/community.piwik.pro/pawel/32/238_2.png) [@Pawel](https://community.piwik.pro/u/Pawel)\
**Post date:** [May 4, 2022, 2:05pm UTC](https://community.piwik.pro/t/unable-to-install-a-container-into-nextjs-project/616/5 "2022-05-04T14:05:04Z")

</div>

Hi! Our developer has found a potential solution:  
Setting `id` on the `Script` element with inline code as recommended in the Next.js docs ([link](https://nextjs.org/docs/basic-features/script#inline-scripts)) has resolved the issue in our test setup. Could you try this solution and let us know if this has helped in your case?

---

<div class="post-metadata">

**Author:** ![kentran](https://avatars.discourse-cdn.com/v4/letter/k/958977/32.png) [@kentran](https://community.piwik.pro/u/kentran)\
**Post date:** [May 6, 2022, 2:08am UTC](https://community.piwik.pro/t/unable-to-install-a-container-into-nextjs-project/616/6 "2022-05-06T02:08:19Z")

</div>

Hi Pawel.  
I tried setting the `id` to the `Script` component but the same error still occurred.  
Would you please check again with your team?

---

<div class="post-metadata">

**Author:** ![Piotrek](https://dub1.discourse-cdn.com/flex005/user_avatar/community.piwik.pro/piotrek/32/160_2.png) [@Piotrek](https://community.piwik.pro/u/Piotrek)\
**Post date:** [September 30, 2022, 11:49am UTC](https://community.piwik.pro/t/unable-to-install-a-container-into-nextjs-project/616/7 "2022-09-30T11:49:47Z")

</div>

Hello @kentran,

This is Piotr from the Data Collection & Integrations team. We wanted to let you know that we are soon going to release a dedicated Piwik PRO library for NextJS. We are planning to release it in the next couple of weeks. Once it’s out, I’ll update this thread with a link. Stay tuned!

---

<div class="post-metadata">

**Author:** ![Piotrek](https://dub1.discourse-cdn.com/flex005/user_avatar/community.piwik.pro/piotrek/32/160_2.png) [@Piotrek](https://community.piwik.pro/u/Piotrek)\
**Post date:** [October 19, 2022, 2:49pm UTC](https://community.piwik.pro/t/unable-to-install-a-container-into-nextjs-project/616/8 "2022-10-19T14:49:02Z")

</div>

@kentran

The tracking library for NextJS is ready and we have released it on our NPM:

> **[@piwikpro/next-piwik-pro](https://www.npmjs.com/package/@piwikpro/next-piwik-pro)**
>
> Piwik PRO tracking library for Next.js. Latest version: 1.0.4, last published: a month ago. Start using @piwikpro/next-piwik-pro in your project by running \`npm i @piwikpro/next-piwik-pro\`. There are no other projects in the npm registry using...

---

<div class="post-metadata">

**Author:** ![kuba](https://dub1.discourse-cdn.com/flex005/user_avatar/community.piwik.pro/kuba/32/7_2.png) [@kuba](https://community.piwik.pro/u/kuba)\
**Post date:** [November 2, 2022, 12:27pm UTC](https://community.piwik.pro/t/unable-to-install-a-container-into-nextjs-project/616/9 "2022-11-02T12:27:04Z")

</div>

A post was split to a new topic: [Problems with NextJS SDK](https://community.piwik.pro/t/problems-with-nextjs-sdk/1201)
