<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have searched the <a href="https://github.com/zeit/next.js/issues?q=is%3Aissue">issues</a> of this repository and believe that this is not a duplicate.</li>
</ul>
<h2 dir="auto">Expected Behavior</h2>
<p dir="auto">GTM tags should work the same way on every page, whether the user arrived at this page or browsed to it.</p>
<h2 dir="auto">Current Behavior</h2>
<p dir="auto">GTM tags that use the <code class="notranslate">event</code> type stop working properly as soon as a user browse the website. By "browse", I mean using client-side navigation, which doesn't refresh the page but only part of it (kinda the point of SPA)</p>
<h2 dir="auto">Steps to Reproduce (for bugs)</h2>
<p dir="auto">You can reproduce on my online staging environment:</p>
<ul dir="auto">
<li>Install Chrome plugin: <a href="https://chrome.google.com/webstore/detail/google-analytics-debugger/jnkmfdileelhofjcijamephohjechhna" rel="nofollow">https://chrome.google.com/webstore/detail/google-analytics-debugger/jnkmfdileelhofjcijamephohjechhna</a> to be able to see the GTM events calls in the browser console</li>
<li>Go to <a href="https://staging.hep.loan-advisor.studylink.fr/idrac" rel="nofollow">https://staging.hep.loan-advisor.studylink.fr/idrac</a></li>
<li>Click on the top-left IDRAC logo, you should see logs on the console (event fired)</li>
<li>Go to <a href="https://staging.hep.loan-advisor.studylink.fr" rel="nofollow">https://staging.hep.loan-advisor.studylink.fr</a> and select the "Idrac" choice from the select input, then click "Go", you should see logs in the console again (redirection detected, which creates a pageview)</li>
<li>Click on the top-left IDRAC logo, you won't see any log this time</li>
</ul>
<h2 dir="auto">Context</h2>
<p dir="auto">I believe that somehow GTM binds some DOM events upon loading that get cleaned when the DOM changes due to Next.js redirection, which reloads the DOM, partially.</p>
<p dir="auto">Those GTM tags (type: event) I'm talking about are basically triggers based on HTML class/id in the DOM. When I use the GTM Preview mode (debug), I can see that there is no gtm.linkClick fired when clicking the logo, if I got redirected from another page using a frontend-redirection. But if I refresh the page and click, it works just fine.</p>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/3807458/38091170-01e963ac-3365-11e8-830a-65fe7f2d7c63.png"><img src="https://user-images.githubusercontent.com/3807458/38091170-01e963ac-3365-11e8-830a-65fe7f2d7c63.png" alt="image" style="max-width: 100%;"></a></p>
<p dir="auto">The simplest workaround I see is to disable client-side redirection but forcing a page refresh, but that's not a nice workaround and kills the point of building an SPA in the first place.</p>
<p dir="auto">Maybe there is a way to force refresh the GTM script (need to clean it from the DOM and add it again because it won't trigger if already loaded), or to use a feature within GTM that binds everything again? I don't know.</p>
<h2 dir="auto">Your Environment</h2>

<table role="table">
<thead>
<tr>
<th>Tech</th>
<th>Version</th>
</tr>
</thead>
<tbody>
<tr>
<td>next</td>
<td>5.0.1-canary.16</td>
</tr>
<tr>
<td>node</td>
<td>6.10.3</td>
</tr>
<tr>
<td>browser</td>
<td>Chrome</td>
</tr>
</tbody>
</table>
<h1 dir="auto">Bug report</h1>
<p dir="auto">Deploying Next to a Firebase function, gets the following error:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="{ Error: Cannot find module '/srv/next/server/static\vk8cHgwKqiKyVYwLtSV~e\pages\_error.js'
    at Function.Module._resolveFilename (module.js:547:15)
    at Function.Module._load (module.js:474:25)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at _callee$ (/srv/node_modules/next/dist/server/require.js:85:46)
    at tryCatch (/srv/node_modules/regenerator-runtime/runtime.js:62:40)
    at Generator.invoke [as _invoke] (/srv/node_modules/regenerator-runtime/runtime.js:288:22)
    at Generator.prototype.(anonymous function) [as next] (/srv/node_modules/regenerator-runtime/runtime.js:114:21)
    at asyncGeneratorStep (/srv/node_modules/@babel/runtime-corejs2/helpers/asyncToGenerator.js:5:24)
    at _next (/srv/node_modules/@babel/runtime-corejs2/helpers/asyncToGenerator.js:27:9) code: 'MODULE_NOT_FOUND' }"><pre class="notranslate"><code class="notranslate">{ Error: Cannot find module '/srv/next/server/static\vk8cHgwKqiKyVYwLtSV~e\pages\_error.js'
    at Function.Module._resolveFilename (module.js:547:15)
    at Function.Module._load (module.js:474:25)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at _callee$ (/srv/node_modules/next/dist/server/require.js:85:46)
    at tryCatch (/srv/node_modules/regenerator-runtime/runtime.js:62:40)
    at Generator.invoke [as _invoke] (/srv/node_modules/regenerator-runtime/runtime.js:288:22)
    at Generator.prototype.(anonymous function) [as next] (/srv/node_modules/regenerator-runtime/runtime.js:114:21)
    at asyncGeneratorStep (/srv/node_modules/@babel/runtime-corejs2/helpers/asyncToGenerator.js:5:24)
    at _next (/srv/node_modules/@babel/runtime-corejs2/helpers/asyncToGenerator.js:27:9) code: 'MODULE_NOT_FOUND' }
</code></pre></div>
<h2 dir="auto">Describe the bug</h2>
<p dir="auto">I think this is because there's a mix of slashes and backslashes in the file name so Node can't find it.</p>
<p dir="auto">The file definitely exists in the correct folder.</p>
<h2 dir="auto">System information</h2>
<ul dir="auto">
<li>OS: Windows</li>
<li>Version of Next.js: 7.0.2</li>
</ul>
<h2 dir="auto">Additional context</h2>
<p dir="auto">Would it make sense to replace all backslashes with slashes in the getPagePath function?</p>