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
2 changes: 1 addition & 1 deletion config/environment.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ declare const config: {
rootURL: string;
assetsPrefix: string;
sentryDSN: string | null;
googleTagManagerId: string | null;
sentryOptions: {
release?: string;
ignoreErrors: string[];
Expand Down Expand Up @@ -195,7 +196,6 @@ declare const config: {
pageTitle: {
prepend: boolean;
};
gtm: string;
};

export default config;
2 changes: 1 addition & 1 deletion config/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ module.exports = function(environment) {
assetsPrefix,
locationType: 'auto',
sentryDSN: null,
googleTagManagerId: null,
sentryOptions: {
release,
ignoreErrors: [
Expand Down Expand Up @@ -303,7 +304,6 @@ module.exports = function(environment) {
pageTitle: {
prepend: false,
},
gtm: '<script></script>',
};

if (environment === 'development') {
Expand Down
13 changes: 12 additions & 1 deletion ember-cli-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,18 @@ module.exports = function(defaults) {
},
gtm: {
enabled: IS_PROD,
content: config.gtm,
content: `<script>
var configJson = document.head.querySelector("meta[name$='/config/environment']").content;
var configObject = JSON.parse(unescape(configJson));
if (configObject.googleTagManagerId) {
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this is relevant, but on prod it looks like this is gtm.js and not js 🤷

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

¯\(ツ)


gtag('config', configObject.googleTagManagerId);
}
</script>
`,
postProcess,
},
},
Expand Down