Skip to content

Commit

Permalink
fix(plugin): find head script (#59)
Browse files Browse the repository at this point in the history
  • Loading branch information
soltanipoor authored Jul 23, 2020
1 parent c86c9ca commit d9deea9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ function gtmServer(ctx, initialized) {
return
}

const gtmScript = ctx.app.head.script.find(s => s.hid = '<%= options.scriptId %>')
const gtmScript = ctx.app.head.script.find(s => s.hid == '<%= options.scriptId %>')
if (inits.length) {
gtmScript.innerHTML += `;${JSON.stringify(inits)}.forEach(function(i){window._gtm_inject(i)})`
}
<% if (options.noscript) { %>
const gtmIframe = ctx.app.head.noscript.find(s => s.hid = '<%= options.noscriptId %>')
const gtmIframe = ctx.app.head.noscript.find(s => s.hid == '<%= options.noscriptId %>')
const renderIframe = id => `<%= options.renderIframe('${id}') %>`
if (inits.length) {
gtmIframe.innerHTML += inits.map(renderIframe)
Expand Down

0 comments on commit d9deea9

Please sign in to comment.