Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,7 @@ misc
queues
TODO.md
types/
misc.js
misc.js

### VisualStudioCode ###
.vscode/*
8 changes: 5 additions & 3 deletions packages/analytics-plugin-google-analytics/src/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,13 @@ function googleAnalytics(pluginConfig = {}) {
initialize: ({ config, instance }) => {
const { dataLayerName, customScriptSrc, gtagName, gtagConfig, debug } = config
/* Inject google gtag.js script if not found */
if (!scriptLoaded(customScriptSrc || gtagScriptSource)) {
const customLayerName = dataLayerName ? `&l=${dataLayerName}` : ''
/* If other gtags are loaded already, add ours anyway */
const customLayerName = dataLayerName ? `&l=${dataLayerName}` : "";
const src = customScriptSrc || `${gtagScriptSource}?id=${measurementIds[0]}${customLayerName}`;
if (!scriptLoaded(src)) {
const script = document.createElement('script')
script.async = true
script.src = customScriptSrc || `${gtagScriptSource}?id=${measurementIds[0]}${customLayerName}`
script.src = src
document.body.appendChild(script)
}
/* Set gtag and datalayer */
Expand Down