Skip to content

Commit

Permalink
Use pixel builder
Browse files Browse the repository at this point in the history
  • Loading branch information
guifromrio committed May 24, 2019
1 parent 3bdef91 commit 56c2484
Show file tree
Hide file tree
Showing 9 changed files with 748 additions and 16 deletions.
13 changes: 13 additions & 0 deletions .editorconfig
@@ -0,0 +1,13 @@
# editorconfig.org
root = true

[*]
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 2
charset = utf-8
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false
7 changes: 5 additions & 2 deletions manifest.json
Expand Up @@ -16,10 +16,13 @@
"free": true
},
"builders": {
"react": "3.x"
"react": "3.x",
"store": "0.x",
"pixel": "0.x"
},
"dependencies": {
"vtex.pixel-manager": "1.0.0-beta.1"
"vtex.pixel-manager": "1.x",
"vtex.store": "2.x"
},
"policies": [
{
Expand Down
13 changes: 6 additions & 7 deletions react/modules/tagManagerScript.js → pixel/head.html
@@ -1,15 +1,14 @@
/* tslint:disable */
export default function addTagManager() {
const gtmId = window.__SETTINGS__[process.env.VTEX_APP_ID].gtmId

<script>
const gtmId = "{{settings.gtmId}}"
if (!gtmId) {
throw new Error('Warning: No Google Tag Manager ID is defined. To setup this app, take a look at your admin')
var workspace = "{{workspace}}"
var adminUrl = 'https://' + (workspace && workspace !== 'master' ? workspace + '--' : '') + '{{account}}.myvtex.com/admin/apps'
console.error('Warning: No Google Tag Manager ID is defined. Please configure it in the apps admin: ' + adminUrl)
}

// GTM script snippet. Taken from: https://developers.google.com/tag-manager/quickstart
(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer',gtmId)
}
</script>

0 comments on commit 56c2484

Please sign in to comment.