forked from sas1ni69/ember-cli-gtm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
18 lines (15 loc) · 985 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/* jshint node: true */
'use strict';
module.exports = {
name: 'ember-cli-gtm',
contentFor: function(type, config) {
var config = config['ember-cli-gtm'];
var appId = config && config.appId;
if (type === 'head' && appId) {
return "<!-- Google Tag Manager --><script>(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','"+ appId +"');</script><!-- End Google Tag Manager -->";
}
if (type === 'body' && appId) {
return '<!-- Google Tag Manager (noscript) --><noscript><iframe src="https://www.googletagmanager.com/ns.html?id=' + appId + '"height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript><!-- End Google Tag Manager (noscript) -->';
}
}
};