diff --git a/dist/angulartics-google-tag-manager.min.js b/dist/angulartics-google-tag-manager.min.js index 7a9f935..95dbad9 100644 --- a/dist/angulartics-google-tag-manager.min.js +++ b/dist/angulartics-google-tag-manager.min.js @@ -1,2 +1,2 @@ -!function(angular){"use strict";angular.module("angulartics.google.tagmanager",["angulartics"]).config(["$analyticsProvider",function($analyticsProvider){function eventTrack(action,properties){var dataLayer=window.dataLayer=window.dataLayer||[];properties=properties||{},dataLayer.push({event:properties.event||"interaction",target:properties.category,action:action,"target-properties":properties.label,value:properties.value,"interaction-type":properties.noninteraction,userId:$analyticsProvider.settings.ga.userId})}$analyticsProvider.settings.ga={userId:null},$analyticsProvider.registerPageTrack(function(path){var dataLayer=window.dataLayer=window.dataLayer||[];dataLayer.push({event:"content-view","content-name":path,userId:$analyticsProvider.settings.ga.userId})}),$analyticsProvider.registerEventTrack(eventTrack),$analyticsProvider.registerExceptionTrack(function(properties){return properties.description?void eventTrack(properties.description,{category:"Exceptions",label:properties.stack}):void console.log("Property description is required to be set")}),$analyticsProvider.registerSetUsername(function(userId){$analyticsProvider.settings.ga.userId=userId})}])}(angular); +!function(angular){"use strict";angular.module("angulartics.google.tagmanager",["angulartics"]).config(["$analyticsProvider",function($analyticsProvider){function eventTrack(eventName,properties){properties=properties||{};var properties2={event:properties.hitType||"event",eventCategory:properties.eventCategory||eventName,eventAction:eventName};properties=angular.extend({},superProperties,properties,properties2),dataLayer.push(properties)}var superProperties={};$analyticsProvider.settings.ga&&dataLayer.push({userId:$analyticsProvider.settings.ga.userId}),$analyticsProvider.registerPageTrack(function(path,$location){var properties={event:"pageview",page:path,hostname:$location.host()};properties=angular.extend({},superProperties,properties),window.dataLayer.push(properties)}),$analyticsProvider.registerEventTrack(eventTrack),$analyticsProvider.registerExceptionTrack(function(error,cause){eventTrack(error.toString(),{eventCategory:"Exceptions",eventLabel:error.stack})}),$analyticsProvider.registerSetUsername(function(username){dataLayer.push({userId:username})}),$analyticsProvider.registerSetSuperProperties(function(properties){for(var property in properties)properties.hasOwnProperty(property)&&(null==properties[property]?superProperties.hasOwnProperty(property)&&delete superProperties[property]:superProperties[property]=properties[property])})}])}(angular); //# sourceMappingURL=../dist/angulartics-google-tag-manager.min.js.map \ No newline at end of file diff --git a/dist/angulartics-google-tag-manager.min.js.map b/dist/angulartics-google-tag-manager.min.js.map index cb321cf..ec9157f 100644 --- a/dist/angulartics-google-tag-manager.min.js.map +++ b/dist/angulartics-google-tag-manager.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["lib/angulartics-google-tag-manager.js"],"names":["angular","module","config","$analyticsProvider","eventTrack","action","properties","dataLayer","window","push","event","target","category","target-properties","label","value","interaction-type","noninteraction","userId","settings","ga","registerPageTrack","path","content-name","registerEventTrack","registerExceptionTrack","description","stack","console","log","registerSetUsername"],"mappings":"CAOA,SAAWA,SACT,YASAA,SAAQC,OAAO,iCAAkC,gBAC9CC,QAAQ,qBAAsB,SAAUC,oBA+BvC,QAASC,YAAWC,OAAQC,YAC1B,GAAIC,WAAYC,OAAOD,UAAYC,OAAOD,aAC1CD,YAAaA,eACbC,UAAUE,MACRC,MAASJ,WAAWI,OAAS,cAC7BC,OAAUL,WAAWM,SACrBP,OAAUA,OACVQ,oBAAqBP,WAAWQ,MAChCC,MAAST,WAAWS,MACpBC,mBAAoBV,WAAWW,eAC/BC,OAAUf,mBAAmBgB,SAASC,GAAGF,SAvC7Cf,mBAAmBgB,SAASC,IAC1BF,OAAQ,MASVf,mBAAmBkB,kBAAkB,SAAUC,MAC7C,GAAIf,WAAYC,OAAOD,UAAYC,OAAOD,aAC1CA,WAAUE,MACRC,MAAS,eACTa,eAAgBD,KAChBJ,OAAUf,mBAAmBgB,SAASC,GAAGF,WAY7Cf,mBAAmBqB,mBAAmBpB,YAwBtCD,mBAAmBsB,uBAAuB,SAAUnB,YAElD,MAAKA,YAAWoB,gBAKhBtB,YAAWE,WAAWoB,aACpBd,SAAY,aACZE,MAASR,WAAWqB,YANpBC,SAAQC,IAAI,gDAkBhB1B,mBAAmB2B,oBAAoB,SAAUZ,QAC/Cf,mBAAmBgB,SAASC,GAAGF,OAASA,aAK7ClB","file":"dist/angulartics-google-tag-manager.min.js","sourceRoot":".."} \ No newline at end of file +{"version":3,"sources":["lib/angulartics-google-tag-manager.js"],"names":["angular","module","config","$analyticsProvider","eventTrack","eventName","properties","properties2","event","hitType","eventCategory","eventAction","extend","superProperties","dataLayer","push","settings","ga","userId","registerPageTrack","path","$location","page","hostname","host","window","registerEventTrack","registerExceptionTrack","error","cause","toString","eventLabel","stack","registerSetUsername","username","registerSetSuperProperties","property","hasOwnProperty"],"mappings":"CAMA,SAAUA,SACN,YAOAA,SAAQC,OAAO,iCAAkC,gBAC5CC,QAAQ,qBAAsB,SAASC,oBAyC7C,QAASC,YAAWC,UAAWC,YAClBA,WAAaA,cACb,IAAIC,cACAC,MAASF,WAAWG,SAAW,QAC/BC,cAAiBJ,WAAWI,eAAiBL,UAC7CM,YAAeN,UAEnBC,YAAaN,QAAQY,UAAWC,gBAAiBP,WAAYC,aAE7DO,UAAUC,KAAKT,YAjDnB,GAAIO,mBAEVV,oBAAmBa,SAASC,IAC9BH,UAAUC,MACMG,OAAUf,mBAAmBa,SAASC,GAAGC,SASjDf,mBAAmBgB,kBAAkB,SAASC,KAAMC,WAChD,GAAIf,aACAE,MAAS,WACTc,KAAQF,KACRG,SAAYF,UAAUG,OAE1BlB,YAAaN,QAAQY,UAAWC,gBAAiBP,YAEjDmB,OAAOX,UAAUC,KAAKT,cAkB1BH,mBAAmBuB,mBAAmBtB,YAoBtCD,mBAAmBwB,uBAAuB,SAASC,MAAOC,OACtDzB,WAAWwB,MAAME,YACbpB,cAAiB,aACjBqB,WAAcH,MAAMI,UAU5B7B,mBAAmB8B,oBAAoB,SAASC,UAC5CpB,UAAUC,MACNG,OAAUgB,aAalB/B,mBAAmBgC,2BAA2B,SAAS7B,YACnD,IAAK,GAAI8B,YAAY9B,YACbA,WAAW+B,eAAeD,YACE,MAAxB9B,WAAW8B,UACPvB,gBAAgBwB,eAAeD,iBACxBvB,iBAAgBuB,UAE3BvB,gBAAgBuB,UAAY9B,WAAW8B,iBAQhEpC","file":"dist/angulartics-google-tag-manager.min.js","sourceRoot":".."} \ No newline at end of file diff --git a/import/classic-analytics-import.json b/import/classic-analytics-import.json index c612df8..ae68524 100644 --- a/import/classic-analytics-import.json +++ b/import/classic-analytics-import.json @@ -305,7 +305,7 @@ { "type": "TEMPLATE", "key": "arg1", - "value": "interaction" + "value": "event" } ] } @@ -331,7 +331,7 @@ { "type": "TEMPLATE", "key": "arg1", - "value": "content-view" + "value": "pageview" } ] } @@ -444,7 +444,7 @@ { "type": "TEMPLATE", "key": "name", - "value": "target" + "value": "eventCategory" }, { "type": "INTEGER", @@ -470,7 +470,7 @@ { "type": "TEMPLATE", "key": "name", - "value": "interaction-type" + "value": "nonInteraction" }, { "type": "INTEGER", @@ -496,7 +496,7 @@ { "type": "TEMPLATE", "key": "name", - "value": "target-properties" + "value": "eventLabel" }, { "type": "INTEGER", @@ -522,7 +522,7 @@ { "type": "TEMPLATE", "key": "name", - "value": "value" + "value": "eventValue" }, { "type": "INTEGER", @@ -548,7 +548,7 @@ { "type": "TEMPLATE", "key": "name", - "value": "content-name" + "value": "page" }, { "type": "INTEGER", diff --git a/import/universal-analytics-import.json b/import/universal-analytics-import.json index 6b5906f..dc54378 100644 --- a/import/universal-analytics-import.json +++ b/import/universal-analytics-import.json @@ -1,67 +1,81 @@ { - "exportFormatVersion": 1.3, - "exportTime": "2015-11-07 02:19:53", + "exportFormatVersion": 2, + "exportTime": "2017-10-23 17:38:09", "containerVersion": { + "path": "accounts/69722640/containers/2338995/versions/9", "accountId": "28896164", - "containerId": "1554238", - "containerVersionId": "0", - "deleted": false, + "containerId": "2338995", + "containerVersionId": "9", + "name": "Angulartics Universal", "container": { + "path": "accounts/28896164/containers/2338995", "accountId": "28896164", - "containerId": "1554238", + "containerId": "2338995", "name": "Angulartics Universal", "publicId": "GTM-KB4VF3", - "timeZoneCountryId": "US", - "timeZoneId": "America/Los_Angeles", - "notes": "", "usageContext": [ "WEB" ], - "fingerprint": "1446862721829" + "fingerprint": "1508712875285", + "tagManagerUrl": "https://tagmanager.google.com/#/container/accounts/28896164/containers/2338995/workspaces?apiLink=container" }, "tag": [ { "accountId": "28896164", - "containerId": "1554238", - "tagId": "9", + "containerId": "2338995", + "tagId": "15", "name": "Angulartics Events", "type": "ua", - "liveOnly": false, "parameter": [ { - "type": "BOOLEAN", - "key": "enableEcommerce", - "value": "false" + "type": "TEMPLATE", + "key": "nonInteraction", + "value": "{{angulartics nonInteraction}}" }, { "type": "BOOLEAN", - "key": "setTrackerName", + "key": "useDebugVersion", "value": "false" }, { - "type": "BOOLEAN", - "key": "doubleClick", - "value": "false" + "type": "TEMPLATE", + "key": "eventCategory", + "value": "{{angulartics eventCategory}}" }, { "type": "TEMPLATE", - "key": "trackingId", - "value": "{{Google Analytics Tracking ID - Angulartics}}" + "key": "trackType", + "value": "TRACK_EVENT" + }, + { + "type": "TEMPLATE", + "key": "eventAction", + "value": "{{angulartics eventAction}}" + }, + { + "type": "TEMPLATE", + "key": "eventLabel", + "value": "{{angulartics eventLabel}}" }, { "type": "BOOLEAN", - "key": "enableLinkId", + "key": "overrideGaSettings", + "value": "true" + }, + { + "type": "BOOLEAN", + "key": "setTrackerName", "value": "false" }, { - "type": "TEMPLATE", - "key": "eventAction", - "value": "{{angulartics event action}}" + "type": "BOOLEAN", + "key": "doubleClick", + "value": "false" }, { "type": "TEMPLATE", "key": "eventValue", - "value": "{{angulartics event value}}" + "value": "{{angulartics eventValue}}" }, { "type": "LIST", @@ -82,6 +96,36 @@ } ] }, + { + "type": "MAP", + "map": [ + { + "type": "TEMPLATE", + "key": "fieldName", + "value": "userId" + }, + { + "type": "TEMPLATE", + "key": "value", + "value": "{{angulartics userId}}" + } + ] + }, + { + "type": "MAP", + "map": [ + { + "type": "TEMPLATE", + "key": "fieldName", + "value": "appName" + }, + { + "type": "TEMPLATE", + "key": "value", + "value": "{{angulartics appName}}" + } + ] + }, { "type": "MAP", "map": [ @@ -93,7 +137,7 @@ { "type": "TEMPLATE", "key": "value", - "value": "{{angulartics page path}}" + "value": "angulart{{angulartics page}}" } ] }, @@ -103,12 +147,12 @@ { "type": "TEMPLATE", "key": "fieldName", - "value": "userId" + "value": "hostname" }, { "type": "TEMPLATE", "key": "value", - "value": "{{angulartics user id}}" + "value": "{{angulartics hostname}}" } ] } @@ -116,49 +160,38 @@ }, { "type": "BOOLEAN", - "key": "useDebugVersion", + "key": "enableLinkId", "value": "false" }, { - "type": "TEMPLATE", - "key": "trackType", - "value": "TRACK_EVENT" - }, - { - "type": "TEMPLATE", - "key": "nonInteraction", - "value": "{{angulartics event interaction type}}" - }, - { - "type": "TEMPLATE", - "key": "eventLabel", - "value": "{{angulartics event label}}" + "type": "BOOLEAN", + "key": "enableEcommerce", + "value": "false" }, { "type": "TEMPLATE", - "key": "eventCategory", - "value": "{{angulartics event category}}" + "key": "trackingId", + "value": "{{UA Google Analytics}}" } ], - "fingerprint": "0", + "fingerprint": "1508712338745", "firingTriggerId": [ - "13" + "21" ], - "parentFolderId": "12", + "parentFolderId": "20", "tagFiringOption": "ONCE_PER_EVENT" }, { "accountId": "28896164", - "containerId": "1554238", - "tagId": "10", + "containerId": "2338995", + "tagId": "16", "name": "Angulartics Pageviews", "type": "ua", - "liveOnly": false, "parameter": [ { "type": "BOOLEAN", - "key": "enableEcommerce", - "value": "false" + "key": "overrideGaSettings", + "value": "true" }, { "type": "BOOLEAN", @@ -167,7 +200,12 @@ }, { "type": "BOOLEAN", - "key": "useHashAutoLink", + "key": "doubleClick", + "value": "false" + }, + { + "type": "BOOLEAN", + "key": "useDebugVersion", "value": "false" }, { @@ -189,6 +227,21 @@ } ] }, + { + "type": "MAP", + "map": [ + { + "type": "TEMPLATE", + "key": "fieldName", + "value": "userId" + }, + { + "type": "TEMPLATE", + "key": "value", + "value": "{{angulartics userId}}" + } + ] + }, { "type": "MAP", "map": [ @@ -200,7 +253,7 @@ { "type": "TEMPLATE", "key": "value", - "value": "{{angulartics page path}}" + "value": "{{angulartics page}}" } ] }, @@ -210,12 +263,27 @@ { "type": "TEMPLATE", "key": "fieldName", - "value": "userId" + "value": "hostname" }, { "type": "TEMPLATE", "key": "value", - "value": "{{angulartics user id}}" + "value": "{{angulartics hostname}}" + } + ] + }, + { + "type": "MAP", + "map": [ + { + "type": "TEMPLATE", + "key": "fieldName", + "value": "appName" + }, + { + "type": "TEMPLATE", + "key": "value", + "value": "{{angulartics appName}}" } ] } @@ -223,13 +291,13 @@ }, { "type": "BOOLEAN", - "key": "doubleClick", + "key": "useHashAutoLink", "value": "false" }, { - "type": "BOOLEAN", - "key": "useDebugVersion", - "value": "false" + "type": "TEMPLATE", + "key": "trackType", + "value": "TRACK_PAGEVIEW" }, { "type": "BOOLEAN", @@ -237,36 +305,35 @@ "value": "false" }, { - "type": "TEMPLATE", - "key": "trackingId", - "value": "{{Google Analytics Tracking ID - Angulartics}}" - }, - { - "type": "TEMPLATE", - "key": "trackType", - "value": "TRACK_PAGEVIEW" + "type": "BOOLEAN", + "key": "enableLinkId", + "value": "false" }, { "type": "BOOLEAN", - "key": "enableLinkId", + "key": "enableEcommerce", "value": "false" + }, + { + "type": "TEMPLATE", + "key": "trackingId", + "value": "{{UA Google Analytics}}" } ], - "fingerprint": "0", + "fingerprint": "1508712367599", "firingTriggerId": [ - "14" + "22" ], - "parentFolderId": "12", + "parentFolderId": "20", "tagFiringOption": "ONCE_PER_EVENT" } ], - "fingerprint": "0", "trigger": [ { "accountId": "28896164", - "containerId": "1554238", - "triggerId": "13", - "name": "Angulartics events", + "containerId": "2338995", + "triggerId": "21", + "name": "Angulartics event Trigger", "type": "CUSTOM_EVENT", "customEventFilter": [ { @@ -280,19 +347,19 @@ { "type": "TEMPLATE", "key": "arg1", - "value": "interaction" + "value": "event" } ] } ], - "fingerprint": "1442427532664", - "parentFolderId": "12" + "fingerprint": "1508709447712", + "parentFolderId": "20" }, { "accountId": "28896164", - "containerId": "1554238", - "triggerId": "14", - "name": "Angulartics pageviews", + "containerId": "2338995", + "triggerId": "22", + "name": "Angulartics pageview Trigger", "type": "CUSTOM_EVENT", "customEventFilter": [ { @@ -306,39 +373,44 @@ { "type": "TEMPLATE", "key": "arg1", - "value": "content-view" + "value": "pageview" } ] } ], - "fingerprint": "1442427532664", - "parentFolderId": "12" + "fingerprint": "1508709426720", + "parentFolderId": "20" } ], "variable": [ { "accountId": "28896164", - "containerId": "1554238", - "variableId": "22", - "name": "Google Analytics Tracking ID - Angulartics", + "containerId": "2338995", + "variableId": "27", + "name": "UA Google Analytics", "type": "c", "parameter": [ { "type": "TEMPLATE", "key": "value", - "value": "UA-XXXXXX-YY" + "value": "UA-64498831-2" } ], - "fingerprint": "0", - "parentFolderId": "12" + "fingerprint": "1508761893180", + "parentFolderId": "20" }, { "accountId": "28896164", - "containerId": "1554238", - "variableId": "23", - "name": "angulartics event action", + "containerId": "2338995", + "variableId": "40", + "name": "angulartics appName", "type": "v", "parameter": [ + { + "type": "INTEGER", + "key": "dataLayerVersion", + "value": "2" + }, { "type": "BOOLEAN", "key": "setDefaultValue", @@ -347,22 +419,43 @@ { "type": "TEMPLATE", "key": "name", - "value": "action" + "value": "appName" + } + ], + "fingerprint": "1508712089005", + "parentFolderId": "20" + }, + { + "accountId": "28896164", + "containerId": "2338995", + "variableId": "32", + "name": "angulartics eventAction", + "type": "v", + "parameter": [ + { + "type": "BOOLEAN", + "key": "setDefaultValue", + "value": "false" }, { "type": "INTEGER", "key": "dataLayerVersion", "value": "2" + }, + { + "type": "TEMPLATE", + "key": "name", + "value": "eventAction" } ], - "fingerprint": "0", - "parentFolderId": "12" + "fingerprint": "1508710984308", + "parentFolderId": "20" }, { "accountId": "28896164", - "containerId": "1554238", - "variableId": "24", - "name": "angulartics event category", + "containerId": "2338995", + "variableId": "33", + "name": "angulartics eventCategory", "type": "v", "parameter": [ { @@ -370,25 +463,25 @@ "key": "setDefaultValue", "value": "false" }, - { - "type": "TEMPLATE", - "key": "name", - "value": "target" - }, { "type": "INTEGER", "key": "dataLayerVersion", "value": "2" + }, + { + "type": "TEMPLATE", + "key": "name", + "value": "eventCategory" } ], - "fingerprint": "0", - "parentFolderId": "12" + "fingerprint": "1508710952316", + "parentFolderId": "20" }, { "accountId": "28896164", - "containerId": "1554238", - "variableId": "25", - "name": "angulartics event interaction type", + "containerId": "2338995", + "variableId": "35", + "name": "angulartics eventLabel", "type": "v", "parameter": [ { @@ -396,25 +489,25 @@ "key": "setDefaultValue", "value": "false" }, - { - "type": "TEMPLATE", - "key": "name", - "value": "interaction-type" - }, { "type": "INTEGER", "key": "dataLayerVersion", "value": "2" + }, + { + "type": "TEMPLATE", + "key": "name", + "value": "eventLabel" } ], - "fingerprint": "0", - "parentFolderId": "12" + "fingerprint": "1508711040007", + "parentFolderId": "20" }, { "accountId": "28896164", - "containerId": "1554238", - "variableId": "26", - "name": "angulartics event label", + "containerId": "2338995", + "variableId": "36", + "name": "angulartics eventValue", "type": "v", "parameter": [ { @@ -422,27 +515,32 @@ "key": "setDefaultValue", "value": "false" }, - { - "type": "TEMPLATE", - "key": "name", - "value": "target-properties" - }, { "type": "INTEGER", "key": "dataLayerVersion", "value": "2" + }, + { + "type": "TEMPLATE", + "key": "name", + "value": "eventValue" } ], - "fingerprint": "0", - "parentFolderId": "12" + "fingerprint": "1508711082943", + "parentFolderId": "20" }, { "accountId": "28896164", - "containerId": "1554238", - "variableId": "27", - "name": "angulartics event value", + "containerId": "2338995", + "variableId": "39", + "name": "angulartics hostname", "type": "v", "parameter": [ + { + "type": "INTEGER", + "key": "dataLayerVersion", + "value": "2" + }, { "type": "BOOLEAN", "key": "setDefaultValue", @@ -451,22 +549,43 @@ { "type": "TEMPLATE", "key": "name", - "value": "value" + "value": "hostname" + } + ], + "fingerprint": "1508709335554", + "parentFolderId": "20" + }, + { + "accountId": "28896164", + "containerId": "2338995", + "variableId": "34", + "name": "angulartics nonInteraction", + "type": "v", + "parameter": [ + { + "type": "BOOLEAN", + "key": "setDefaultValue", + "value": "false" }, { "type": "INTEGER", "key": "dataLayerVersion", "value": "2" + }, + { + "type": "TEMPLATE", + "key": "name", + "value": "nonInteraction" } ], - "fingerprint": "0", - "parentFolderId": "12" + "fingerprint": "1508711130117", + "parentFolderId": "20" }, { "accountId": "28896164", - "containerId": "1554238", - "variableId": "28", - "name": "angulartics page path", + "containerId": "2338995", + "variableId": "37", + "name": "angulartics page", "type": "v", "parameter": [ { @@ -474,25 +593,25 @@ "key": "setDefaultValue", "value": "false" }, - { - "type": "TEMPLATE", - "key": "name", - "value": "content-name" - }, { "type": "INTEGER", "key": "dataLayerVersion", "value": "2" + }, + { + "type": "TEMPLATE", + "key": "name", + "value": "page" } ], - "fingerprint": "0", - "parentFolderId": "12" + "fingerprint": "1508709170945", + "parentFolderId": "20" }, { "accountId": "28896164", - "containerId": "1554238", - "variableId": "30", - "name": "angulartics user id", + "containerId": "2338995", + "variableId": "38", + "name": "angulartics userId", "type": "v", "parameter": [ { @@ -500,28 +619,153 @@ "key": "setDefaultValue", "value": "false" }, - { - "type": "TEMPLATE", - "key": "name", - "value": "userId" - }, { "type": "INTEGER", "key": "dataLayerVersion", "value": "2" + }, + { + "type": "TEMPLATE", + "key": "name", + "value": "userId" } ], - "fingerprint": "0" + "fingerprint": "1508709606393", + "parentFolderId": "20" } ], "folder": [ { "accountId": "28896164", - "containerId": "1554238", - "folderId": "12", + "containerId": "2338995", + "folderId": "20", "name": "Angulartics", - "fingerprint": "1442427532662" + "fingerprint": "1508610507218" } - ] + ], + "builtInVariable": [ + { + "accountId": "28896164", + "containerId": "2338995", + "type": "PAGE_URL", + "name": "Page URL" + }, + { + "accountId": "28896164", + "containerId": "2338995", + "type": "PAGE_HOSTNAME", + "name": "Page Hostname" + }, + { + "accountId": "28896164", + "containerId": "2338995", + "type": "PAGE_PATH", + "name": "Page Path" + }, + { + "accountId": "28896164", + "containerId": "2338995", + "type": "REFERRER", + "name": "Referrer" + }, + { + "accountId": "28896164", + "containerId": "2338995", + "type": "EVENT", + "name": "Event" + }, + { + "accountId": "28896164", + "containerId": "2338995", + "type": "CLICK_ELEMENT", + "name": "Click Element" + }, + { + "accountId": "28896164", + "containerId": "2338995", + "type": "CLICK_CLASSES", + "name": "Click Classes" + }, + { + "accountId": "28896164", + "containerId": "2338995", + "type": "CLICK_ID", + "name": "Click ID" + }, + { + "accountId": "28896164", + "containerId": "2338995", + "type": "CLICK_TARGET", + "name": "Click Target" + }, + { + "accountId": "28896164", + "containerId": "2338995", + "type": "CLICK_URL", + "name": "Click URL" + }, + { + "accountId": "28896164", + "containerId": "2338995", + "type": "CLICK_TEXT", + "name": "Click Text" + }, + { + "accountId": "28896164", + "containerId": "2338995", + "type": "FORM_ELEMENT", + "name": "Form Element" + }, + { + "accountId": "28896164", + "containerId": "2338995", + "type": "FORM_CLASSES", + "name": "Form Classes" + }, + { + "accountId": "28896164", + "containerId": "2338995", + "type": "FORM_ID", + "name": "Form ID" + }, + { + "accountId": "28896164", + "containerId": "2338995", + "type": "FORM_TARGET", + "name": "Form Target" + }, + { + "accountId": "28896164", + "containerId": "2338995", + "type": "FORM_URL", + "name": "Form URL" + }, + { + "accountId": "28896164", + "containerId": "2338995", + "type": "FORM_TEXT", + "name": "Form Text" + }, + { + "accountId": "28896164", + "containerId": "2338995", + "type": "CONTAINER_VERSION", + "name": "Container Version" + }, + { + "accountId": "28896164", + "containerId": "2338995", + "type": "RANDOM_NUMBER", + "name": "Random Number" + }, + { + "accountId": "28896164", + "containerId": "2338995", + "type": "CONTAINER_ID", + "name": "Container ID" + } + ], + "fingerprint": "1508763529893", + "tagManagerUrl": "https://tagmanager.google.com/#/versions/accounts/28896164/containers/2338995/versions/9?apiLink=version" } } \ No newline at end of file diff --git a/lib/angulartics-google-tag-manager.js b/lib/angulartics-google-tag-manager.js index ec7f0ce..48f3b18 100644 --- a/lib/angulartics-google-tag-manager.js +++ b/lib/angulartics-google-tag-manager.js @@ -4,92 +4,116 @@ * Google Tag Manager Plugin Contributed by http://github.com/danrowe49 * License: MIT */ - -(function (angular) { - 'use strict'; - - - /** - * @ngdoc overview - * @name angulartics.google.analytics - * Enables analytics support for Google Tag Manager (http://google.com/tagmanager) - */ - - angular.module('angulartics.google.tagmanager', ['angulartics']) - .config(['$analyticsProvider', function ($analyticsProvider) { - - $analyticsProvider.settings.ga = { - userId: null - }; - - /** - * Send content views to the dataLayer - * - * @param {string} path Required 'content name' (string) describes the content loaded - */ - - $analyticsProvider.registerPageTrack(function (path) { - var dataLayer = window.dataLayer = window.dataLayer || []; - dataLayer.push({ - 'event': 'content-view', - 'content-name': path, - 'userId': $analyticsProvider.settings.ga.userId - }); - }); - - /** - * Send interactions to the dataLayer, i.e. for event tracking in Google Analytics - * @name eventTrack - * - * @param {string} action Required 'action' (string) associated with the event - * @param {object} properties Comprised of the mandatory field 'category' (string) and optional fields 'label' (string), 'value' (integer) and 'noninteraction' (boolean) - */ - - $analyticsProvider.registerEventTrack(eventTrack); - - function eventTrack(action, properties) { - var dataLayer = window.dataLayer = window.dataLayer || []; - properties = properties || {}; - dataLayer.push({ - 'event': properties.event || 'interaction', - 'target': properties.category, - 'action': action, - 'target-properties': properties.label, - 'value': properties.value, - 'interaction-type': properties.noninteraction, - 'userId': $analyticsProvider.settings.ga.userId - }); - - } - - /** - * Send exceptions to the dataLayer, reusing the existing Event Tracking tag in GTM - * @name exceptionTrack - * - * @param {object} error An Error object to track: error.toString() used for event 'action', error.stack used for event 'label'. - * @param {object} cause The cause of the error given from $exceptionHandler, not used - */ - - $analyticsProvider.registerExceptionTrack(function(error, cause) { - - eventTrack(error.toString(), { - 'category': 'Exceptions', - 'label': error.stack - }); - - }); - - /** - * Set userId for use with Universal Analytics User ID feature - * @name setUsername - * - * @param {string} userId Required 'userId' value (string) used to identify user cross-device in Google Analytics - */ - - $analyticsProvider.registerSetUsername(function (userId) { - $analyticsProvider.settings.ga.userId = userId; - }); - - }]); +(function(angular) { + 'use strict'; + + /** + * @ngdoc overview + * @name angulartics.google.analytics + * Enables analytics support for Google Tag Manager (http://google.com/tagmanager) + */ + angular.module('angulartics.google.tagmanager', ['angulartics']) + .config(['$analyticsProvider', function($analyticsProvider) { + var superProperties = {}; + //backward compatibility with previous version + if($analyticsProvider.settings.ga) { + dataLayer.push({ + 'userId': $analyticsProvider.settings.ga.userId + }); + } + + /** + * Track pageview in GTM by sending to the dataLayer, GTM shall then convert them into events for Google Analytics + * + * @param {string} path Required 'content name' (string) describes the content loaded + */ + $analyticsProvider.registerPageTrack(function(path, $location) { + var properties = { + 'event': 'pageview', + 'page': path, + 'hostname': $location.host() + }; + properties = angular.extend({}, superProperties, properties); + + window.dataLayer.push(properties); + }); + + /** + * Track hits/events in GTM (by sending them to the dataLayer), + * GTM shall then convert them into hits/events for Google Analytics + * @name eventTrack + * + * @param {string} eventName Required 'eventAction' (string) associated with the event + * @param {object} properties Comprised of the mandatory fields: + * 'hitType' (string default='event') + * 'eventCategory' (string default=eventName) + * and the optional fields: + * 'eventLabel' (string), 'eventValue' (integer), 'nonInteraction' (boolean), + * and any other Google analytics fields (see @link) as long as they are also defined in GTM + * + * @link https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#hitType + */ + $analyticsProvider.registerEventTrack(eventTrack); + function eventTrack(eventName, properties) { + properties = properties || {}; + var properties2 = { + 'event': properties.hitType || 'event', + 'eventCategory': properties.eventCategory || eventName, + 'eventAction': eventName + }; + properties = angular.extend({}, superProperties, properties, properties2); + + dataLayer.push(properties); + } + + /** + * Send exceptions to the dataLayer, reusing the existing Event Tracking tag in GTM + * @name exceptionTrack + * + * @param {object} error An Error object to track: error.toString() used for 'eventAction', error.stack used for 'eventLabel'. + * @param {object} cause The cause of the error given from $exceptionHandler, not used + */ + $analyticsProvider.registerExceptionTrack(function(error, cause) { + eventTrack(error.toString(), { + 'eventCategory': 'Exceptions', + 'eventLabel': error.stack + }); + }); + + /** + * Set userId for use with Universal Analytics userId feature + * @name setUsername + * + * @param {string} userId Required 'userId' value (string) used to identify user cross-device in Google Analytics + */ + $analyticsProvider.registerSetUsername(function(username) { + dataLayer.push({ + 'userId': username + }); + }); + + /** + * Set super properties to be added to all $analytics.pagetTrack and $analytics.eventTrack + * To remove a property, set its value to null + * + * @param {object} properties = { superProperty1: value, superPropertyToRemove: null, superProperty2...} + * properties like 'appName' (string) or any other Google analytics fields (see @link) as long as they are also defined in GTM + * + * @link https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#hitType + */ + $analyticsProvider.registerSetSuperProperties(function(properties) { + for (var property in properties) { + if (properties.hasOwnProperty(property)) { + if (properties[property] == null) { + if (superProperties.hasOwnProperty(property)) + delete superProperties[property]; + } else { + superProperties[property] = properties[property]; + } + } + } + }); + + }]); })(angular); diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..6aa0bd3 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,142 @@ +{ + "name": "angulartics-google-tag-manager", + "version": "0.0.1", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "align-text": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/align-text/-/align-text-0.1.4.tgz", + "integrity": "sha1-DNkKVhCT810KmSVsIrcGlDP60Rc=", + "dev": true, + "requires": { + "kind-of": "3.2.2", + "longest": "1.0.1", + "repeat-string": "1.6.1" + } + }, + "camelcase": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-1.2.1.tgz", + "integrity": "sha1-m7UwTS4LVmmLLHWLCKPqqdqlijk=", + "dev": true + }, + "center-align": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/center-align/-/center-align-0.1.3.tgz", + "integrity": "sha1-qg0yYptu6XIgBBHL1EYckHvCt60=", + "dev": true, + "requires": { + "align-text": "0.1.4", + "lazy-cache": "1.0.4" + } + }, + "cliui": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-2.1.0.tgz", + "integrity": "sha1-S0dXYP+AJkx2LDoXGQMukcf+oNE=", + "dev": true, + "requires": { + "center-align": "0.1.3", + "right-align": "0.1.3", + "wordwrap": "0.0.2" + } + }, + "decamelize": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", + "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=", + "dev": true + }, + "is-buffer": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.5.tgz", + "integrity": "sha1-Hzsm72E7IUuIy8ojzGwB2Hlh7sw=", + "dev": true + }, + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "1.1.5" + } + }, + "lazy-cache": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/lazy-cache/-/lazy-cache-1.0.4.tgz", + "integrity": "sha1-odePw6UEdMuAhF07O24dpJpEbo4=", + "dev": true + }, + "longest": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/longest/-/longest-1.0.1.tgz", + "integrity": "sha1-MKCy2jj3N3DoKUoNIuZiXtd9AJc=", + "dev": true + }, + "repeat-string": { + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz", + "integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc=", + "dev": true + }, + "right-align": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/right-align/-/right-align-0.1.3.tgz", + "integrity": "sha1-YTObci/mo1FWiSENJOFMlhSGE+8=", + "dev": true, + "requires": { + "align-text": "0.1.4" + } + }, + "source-map": { + "version": "0.5.7", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", + "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", + "dev": true + }, + "uglify-js": { + "version": "2.8.29", + "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-2.8.29.tgz", + "integrity": "sha1-KcVzMUgFe7Th913zW3qcty5qWd0=", + "dev": true, + "requires": { + "source-map": "0.5.7", + "uglify-to-browserify": "1.0.2", + "yargs": "3.10.0" + } + }, + "uglify-to-browserify": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/uglify-to-browserify/-/uglify-to-browserify-1.0.2.tgz", + "integrity": "sha1-bgkk1r2mta/jSeOabWMoUKD4grc=", + "dev": true, + "optional": true + }, + "window-size": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/window-size/-/window-size-0.1.0.tgz", + "integrity": "sha1-VDjNLqk7IC76Ohn+iIeu58lPnJ0=", + "dev": true + }, + "wordwrap": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.2.tgz", + "integrity": "sha1-t5Zpu0LstAn4PVg8rVLKF+qhZD8=", + "dev": true + }, + "yargs": { + "version": "3.10.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-3.10.0.tgz", + "integrity": "sha1-9+572FfdfB0tOMDnTvvWgdFDH9E=", + "dev": true, + "requires": { + "camelcase": "1.2.1", + "cliui": "2.1.0", + "decamelize": "1.2.0", + "window-size": "0.1.0" + } + } + } +} diff --git a/package.json b/package.json index 7ecab44..ec048f4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "angulartics-google-tag-manager", - "version": "0.0.1", + "version": "0.1.0", "description": "Google Tag Manager plugin for Angulartics", "keywords": [ "google", diff --git a/readme.md b/readme.md index 8f60247..55365c4 100644 --- a/readme.md +++ b/readme.md @@ -92,22 +92,22 @@ Naming and case must match. * Name: **angulartics page path** * Type: **Data Layer Variable** - * Data Layer Variable Name: **content-name** + * Data Layer Variable Name: **page** * Name: **angulartics event category** * Type: **Data Layer Variable** - * Data Layer Variable Name: **target** + * Data Layer Variable Name: **eventCategory** * Name: **angulartics event action** * Type: **Data Layer Variable** - * Data Layer Variable Name: **action** + * Data Layer Variable Name: **eventAction** * Name: **angulartics event label** * Type: **Data Layer Variable** - * Data Layer Variable Name: **target-properties** + * Data Layer Variable Name: **eventLabel** * Name: **angulartics event value** * Macro Type: **Data Layer Variable** - * Data Layer Variable Name: **value** + * Data Layer Variable Name: **eventValue** * Name: **angulartics event interaction type** * Type: **Data Layer Variable** - * Data Layer Variable Name: **interaction-type** + * Data Layer Variable Name: **nonInteraction** * (OPTIONAL) **angulartics user id** * Type: **Data Layer Variable** * Data Layer Variable Name: **userId** @@ -118,10 +118,10 @@ Name and case must match. * Name: **Angulartics events** * Event: **Custom Event** - * Event name: **interaction** + * Event name: **event** * Name: **Angulartics pageviews** * Event: **Custom Event** - * Event name: **content-view** + * Event name: **page** **2 Tags** @@ -159,22 +159,22 @@ Naming and case must match. * Name: **angulartics page path** * Type: **Data Layer Variable** - * Data Layer Variable Name: **content-name** + * Data Layer Variable Name: **page** * Name: **angulartics event category** * Type: **Data Layer Variable** - * Data Layer Variable Name: **target** + * Data Layer Variable Name: **eventCategory** * Name: **angulartics event action** * Type: **Data Layer Variable** - * Data Layer Variable Name: **action** + * Data Layer Variable Name: **eventAction** * Name: **angulartics event label** * Type: **Data Layer Variable** - * Data Layer Variable Name: **target-properties** + * Data Layer Variable Name: **eventLabel** * Name: **angulartics event value** * Macro Type: **Data Layer Variable** - * Data Layer Variable Name: **value** + * Data Layer Variable Name: **eventValue** * Name: **angulartics event interaction type** * Type: **Data Layer Variable** - * Data Layer Variable Name: **interaction-type** + * Data Layer Variable Name: **nonInteraction** **2 Triggers** @@ -182,10 +182,10 @@ Name and case must match. * Name: **Angulartics events** * Event: **Custom Event** - * Event name: **interaction** + * Event name: **event** * Name: **Angulartics pageviews** * Event: **Custom Event** - * Event name: **content-view** + * Event name: **page** **2 Tags**