├── .gitignore ├── bower.json ├── dist ├── angulartics-google-tag-manager.min.js └── angulartics-google-tag-manager.min.js.map ├── import ├── classic-analytics-import.json └── universal-analytics-import.json ├── lib ├── angulartics-google-tag-manager.js └── index.js ├── package.json └── readme.md /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | *.DS_STORE 3 | -------------------------------------------------------------------------------- /bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "angulartics-google-tag-manager", 3 | "homepage": "https://github.com/angulartics/angulartics-google-tag-manager", 4 | "contributors": [ 5 | "Jared Dickson " 6 | ], 7 | "description": "Google Tag Manager plugin for Angulartics", 8 | "main": "lib/angulartics-google-tag-manager.js", 9 | "license": "MIT", 10 | "ignore": [ 11 | "**/.*", 12 | "node_modules", 13 | "bower_components", 14 | "package.json", 15 | "lib/index.js" 16 | ], 17 | "dependencies": { 18 | "angulartics": "^1.0.0" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /dist/angulartics-google-tag-manager.min.js: -------------------------------------------------------------------------------- 1 | !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); 2 | //# sourceMappingURL=../dist/angulartics-google-tag-manager.min.js.map -------------------------------------------------------------------------------- /dist/angulartics-google-tag-manager.min.js.map: -------------------------------------------------------------------------------- 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":".."} -------------------------------------------------------------------------------- /import/classic-analytics-import.json: -------------------------------------------------------------------------------- 1 | { 2 | "exportFormatVersion": 1.3, 3 | "exportTime": "2015-11-07 02:23:02", 4 | "containerVersion": { 5 | "accountId": "28896164", 6 | "containerId": "1664526", 7 | "containerVersionId": "0", 8 | "deleted": false, 9 | "container": { 10 | "accountId": "28896164", 11 | "containerId": "1664526", 12 | "name": "Angulartics Classic", 13 | "publicId": "GTM-TZS25Z", 14 | "timeZoneCountryId": "US", 15 | "timeZoneId": "America/Los_Angeles", 16 | "notes": "", 17 | "usageContext": [ 18 | "WEB" 19 | ], 20 | "fingerprint": "1446862963736", 21 | "enabledBuiltInVariable": [ 22 | "PAGE_HOSTNAME" 23 | ] 24 | }, 25 | "tag": [ 26 | { 27 | "accountId": "28896164", 28 | "containerId": "1664526", 29 | "tagId": "3", 30 | "name": "Angulartics Events", 31 | "type": "ga", 32 | "liveOnly": false, 33 | "parameter": [ 34 | { 35 | "type": "BOOLEAN", 36 | "key": "setTrackerName", 37 | "value": "false" 38 | }, 39 | { 40 | "type": "BOOLEAN", 41 | "key": "detectFlash", 42 | "value": "true" 43 | }, 44 | { 45 | "type": "BOOLEAN", 46 | "key": "doubleClick", 47 | "value": "false" 48 | }, 49 | { 50 | "type": "BOOLEAN", 51 | "key": "allowAnchor", 52 | "value": "false" 53 | }, 54 | { 55 | "type": "TEMPLATE", 56 | "key": "domainName", 57 | "value": "{{Google Analytics Cookie Domain - Angulartics}}" 58 | }, 59 | { 60 | "type": "BOOLEAN", 61 | "key": "forceSsl", 62 | "value": "false" 63 | }, 64 | { 65 | "type": "BOOLEAN", 66 | "key": "clientInfo", 67 | "value": "true" 68 | }, 69 | { 70 | "type": "BOOLEAN", 71 | "key": "anonymizeIp", 72 | "value": "false" 73 | }, 74 | { 75 | "type": "LIST", 76 | "key": "ignoredRef" 77 | }, 78 | { 79 | "type": "BOOLEAN", 80 | "key": "allowLinker", 81 | "value": "false" 82 | }, 83 | { 84 | "type": "TEMPLATE", 85 | "key": "eventAction", 86 | "value": "{{angulartics event action}}" 87 | }, 88 | { 89 | "type": "TEMPLATE", 90 | "key": "eventValue", 91 | "value": "{{angulartics event value}}" 92 | }, 93 | { 94 | "type": "LIST", 95 | "key": "ignoredOrganic" 96 | }, 97 | { 98 | "type": "LIST", 99 | "key": "cookiePathCopy" 100 | }, 101 | { 102 | "type": "TEMPLATE", 103 | "key": "webPropertyId", 104 | "value": "{{Google Analytics Tracking ID - Angulartics}}" 105 | }, 106 | { 107 | "type": "BOOLEAN", 108 | "key": "detectTitle", 109 | "value": "true" 110 | }, 111 | { 112 | "type": "TEMPLATE", 113 | "key": "page", 114 | "value": "{{angulartics page path}}" 115 | }, 116 | { 117 | "type": "BOOLEAN", 118 | "key": "useDebugVersion", 119 | "value": "false" 120 | }, 121 | { 122 | "type": "BOOLEAN", 123 | "key": "campaignTrack", 124 | "value": "true" 125 | }, 126 | { 127 | "type": "TEMPLATE", 128 | "key": "trackType", 129 | "value": "TRACK_EVENT" 130 | }, 131 | { 132 | "type": "BOOLEAN", 133 | "key": "enableInPageLinkId", 134 | "value": "false" 135 | }, 136 | { 137 | "type": "BOOLEAN", 138 | "key": "allowHash", 139 | "value": "true" 140 | }, 141 | { 142 | "type": "BOOLEAN", 143 | "key": "sendHitsToGoogle", 144 | "value": "true" 145 | }, 146 | { 147 | "type": "TEMPLATE", 148 | "key": "nonInteraction", 149 | "value": "{{angulartics event interaction type}}" 150 | }, 151 | { 152 | "type": "TEMPLATE", 153 | "key": "eventLabel", 154 | "value": "{{angulartics event label}}" 155 | }, 156 | { 157 | "type": "TEMPLATE", 158 | "key": "eventCategory", 159 | "value": "{{angulartics event category}}" 160 | } 161 | ], 162 | "fingerprint": "0", 163 | "firingTriggerId": [ 164 | "5" 165 | ], 166 | "parentFolderId": "4", 167 | "tagFiringOption": "ONCE_PER_EVENT" 168 | }, 169 | { 170 | "accountId": "28896164", 171 | "containerId": "1664526", 172 | "tagId": "4", 173 | "name": "Angulartics Pageviews", 174 | "type": "ga", 175 | "liveOnly": false, 176 | "parameter": [ 177 | { 178 | "type": "BOOLEAN", 179 | "key": "setTrackerName", 180 | "value": "false" 181 | }, 182 | { 183 | "type": "BOOLEAN", 184 | "key": "detectFlash", 185 | "value": "true" 186 | }, 187 | { 188 | "type": "BOOLEAN", 189 | "key": "doubleClick", 190 | "value": "false" 191 | }, 192 | { 193 | "type": "BOOLEAN", 194 | "key": "forceSsl", 195 | "value": "false" 196 | }, 197 | { 198 | "type": "BOOLEAN", 199 | "key": "allowAnchor", 200 | "value": "false" 201 | }, 202 | { 203 | "type": "TEMPLATE", 204 | "key": "domainName", 205 | "value": "{{Google Analytics Cookie Domain - Angulartics}}" 206 | }, 207 | { 208 | "type": "BOOLEAN", 209 | "key": "clientInfo", 210 | "value": "true" 211 | }, 212 | { 213 | "type": "BOOLEAN", 214 | "key": "allowLinker", 215 | "value": "false" 216 | }, 217 | { 218 | "type": "LIST", 219 | "key": "ignoredRef" 220 | }, 221 | { 222 | "type": "BOOLEAN", 223 | "key": "anonymizeIp", 224 | "value": "false" 225 | }, 226 | { 227 | "type": "LIST", 228 | "key": "cookiePathCopy" 229 | }, 230 | { 231 | "type": "LIST", 232 | "key": "ignoredOrganic" 233 | }, 234 | { 235 | "type": "TEMPLATE", 236 | "key": "webPropertyId", 237 | "value": "{{Google Analytics Tracking ID - Angulartics}}" 238 | }, 239 | { 240 | "type": "BOOLEAN", 241 | "key": "detectTitle", 242 | "value": "true" 243 | }, 244 | { 245 | "type": "TEMPLATE", 246 | "key": "page", 247 | "value": "{{angulartics page path}}" 248 | }, 249 | { 250 | "type": "BOOLEAN", 251 | "key": "useDebugVersion", 252 | "value": "false" 253 | }, 254 | { 255 | "type": "BOOLEAN", 256 | "key": "campaignTrack", 257 | "value": "true" 258 | }, 259 | { 260 | "type": "TEMPLATE", 261 | "key": "trackType", 262 | "value": "TRACK_PAGEVIEW" 263 | }, 264 | { 265 | "type": "BOOLEAN", 266 | "key": "enableInPageLinkId", 267 | "value": "false" 268 | }, 269 | { 270 | "type": "BOOLEAN", 271 | "key": "allowHash", 272 | "value": "true" 273 | }, 274 | { 275 | "type": "BOOLEAN", 276 | "key": "sendHitsToGoogle", 277 | "value": "true" 278 | } 279 | ], 280 | "fingerprint": "0", 281 | "firingTriggerId": [ 282 | "6" 283 | ], 284 | "parentFolderId": "4", 285 | "tagFiringOption": "ONCE_PER_EVENT" 286 | } 287 | ], 288 | "fingerprint": "0", 289 | "trigger": [ 290 | { 291 | "accountId": "28896164", 292 | "containerId": "1664526", 293 | "triggerId": "5", 294 | "name": "Angulartics events", 295 | "type": "CUSTOM_EVENT", 296 | "customEventFilter": [ 297 | { 298 | "type": "EQUALS", 299 | "parameter": [ 300 | { 301 | "type": "TEMPLATE", 302 | "key": "arg0", 303 | "value": "{{_event}}" 304 | }, 305 | { 306 | "type": "TEMPLATE", 307 | "key": "arg1", 308 | "value": "interaction" 309 | } 310 | ] 311 | } 312 | ], 313 | "fingerprint": "1445862705450", 314 | "parentFolderId": "4" 315 | }, 316 | { 317 | "accountId": "28896164", 318 | "containerId": "1664526", 319 | "triggerId": "6", 320 | "name": "Angulartics pageviews", 321 | "type": "CUSTOM_EVENT", 322 | "customEventFilter": [ 323 | { 324 | "type": "EQUALS", 325 | "parameter": [ 326 | { 327 | "type": "TEMPLATE", 328 | "key": "arg0", 329 | "value": "{{_event}}" 330 | }, 331 | { 332 | "type": "TEMPLATE", 333 | "key": "arg1", 334 | "value": "content-view" 335 | } 336 | ] 337 | } 338 | ], 339 | "fingerprint": "1445862705450", 340 | "parentFolderId": "4" 341 | } 342 | ], 343 | "variable": [ 344 | { 345 | "accountId": "28896164", 346 | "containerId": "1664526", 347 | "variableId": "17", 348 | "name": "Google Analytics Cookie Domain - Angulartics", 349 | "type": "smm", 350 | "parameter": [ 351 | { 352 | "type": "TEMPLATE", 353 | "key": "input", 354 | "value": "{{Page Hostname}}" 355 | }, 356 | { 357 | "type": "BOOLEAN", 358 | "key": "setDefaultValue", 359 | "value": "true" 360 | }, 361 | { 362 | "type": "LIST", 363 | "key": "map", 364 | "list": [ 365 | { 366 | "type": "MAP", 367 | "map": [ 368 | { 369 | "type": "TEMPLATE", 370 | "key": "key", 371 | "value": "localhost" 372 | }, 373 | { 374 | "type": "TEMPLATE", 375 | "key": "value", 376 | "value": "none" 377 | } 378 | ] 379 | } 380 | ] 381 | }, 382 | { 383 | "type": "TEMPLATE", 384 | "key": "defaultValue", 385 | "value": "{{Page Hostname}}" 386 | } 387 | ], 388 | "fingerprint": "0" 389 | }, 390 | { 391 | "accountId": "28896164", 392 | "containerId": "1664526", 393 | "variableId": "9", 394 | "name": "Google Analytics Tracking ID - Angulartics", 395 | "type": "c", 396 | "parameter": [ 397 | { 398 | "type": "TEMPLATE", 399 | "key": "value", 400 | "value": "UA-XXXXXX-YY" 401 | } 402 | ], 403 | "fingerprint": "0", 404 | "parentFolderId": "4" 405 | }, 406 | { 407 | "accountId": "28896164", 408 | "containerId": "1664526", 409 | "variableId": "11", 410 | "name": "angulartics event action", 411 | "type": "v", 412 | "parameter": [ 413 | { 414 | "type": "BOOLEAN", 415 | "key": "setDefaultValue", 416 | "value": "false" 417 | }, 418 | { 419 | "type": "TEMPLATE", 420 | "key": "name", 421 | "value": "action" 422 | }, 423 | { 424 | "type": "INTEGER", 425 | "key": "dataLayerVersion", 426 | "value": "2" 427 | } 428 | ], 429 | "fingerprint": "0", 430 | "parentFolderId": "4" 431 | }, 432 | { 433 | "accountId": "28896164", 434 | "containerId": "1664526", 435 | "variableId": "12", 436 | "name": "angulartics event category", 437 | "type": "v", 438 | "parameter": [ 439 | { 440 | "type": "BOOLEAN", 441 | "key": "setDefaultValue", 442 | "value": "false" 443 | }, 444 | { 445 | "type": "TEMPLATE", 446 | "key": "name", 447 | "value": "target" 448 | }, 449 | { 450 | "type": "INTEGER", 451 | "key": "dataLayerVersion", 452 | "value": "2" 453 | } 454 | ], 455 | "fingerprint": "0", 456 | "parentFolderId": "4" 457 | }, 458 | { 459 | "accountId": "28896164", 460 | "containerId": "1664526", 461 | "variableId": "13", 462 | "name": "angulartics event interaction type", 463 | "type": "v", 464 | "parameter": [ 465 | { 466 | "type": "BOOLEAN", 467 | "key": "setDefaultValue", 468 | "value": "false" 469 | }, 470 | { 471 | "type": "TEMPLATE", 472 | "key": "name", 473 | "value": "interaction-type" 474 | }, 475 | { 476 | "type": "INTEGER", 477 | "key": "dataLayerVersion", 478 | "value": "2" 479 | } 480 | ], 481 | "fingerprint": "0", 482 | "parentFolderId": "4" 483 | }, 484 | { 485 | "accountId": "28896164", 486 | "containerId": "1664526", 487 | "variableId": "14", 488 | "name": "angulartics event label", 489 | "type": "v", 490 | "parameter": [ 491 | { 492 | "type": "BOOLEAN", 493 | "key": "setDefaultValue", 494 | "value": "false" 495 | }, 496 | { 497 | "type": "TEMPLATE", 498 | "key": "name", 499 | "value": "target-properties" 500 | }, 501 | { 502 | "type": "INTEGER", 503 | "key": "dataLayerVersion", 504 | "value": "2" 505 | } 506 | ], 507 | "fingerprint": "0", 508 | "parentFolderId": "4" 509 | }, 510 | { 511 | "accountId": "28896164", 512 | "containerId": "1664526", 513 | "variableId": "15", 514 | "name": "angulartics event value", 515 | "type": "v", 516 | "parameter": [ 517 | { 518 | "type": "BOOLEAN", 519 | "key": "setDefaultValue", 520 | "value": "false" 521 | }, 522 | { 523 | "type": "TEMPLATE", 524 | "key": "name", 525 | "value": "value" 526 | }, 527 | { 528 | "type": "INTEGER", 529 | "key": "dataLayerVersion", 530 | "value": "2" 531 | } 532 | ], 533 | "fingerprint": "0", 534 | "parentFolderId": "4" 535 | }, 536 | { 537 | "accountId": "28896164", 538 | "containerId": "1664526", 539 | "variableId": "16", 540 | "name": "angulartics page path", 541 | "type": "v", 542 | "parameter": [ 543 | { 544 | "type": "BOOLEAN", 545 | "key": "setDefaultValue", 546 | "value": "false" 547 | }, 548 | { 549 | "type": "TEMPLATE", 550 | "key": "name", 551 | "value": "content-name" 552 | }, 553 | { 554 | "type": "INTEGER", 555 | "key": "dataLayerVersion", 556 | "value": "2" 557 | } 558 | ], 559 | "fingerprint": "0", 560 | "parentFolderId": "4" 561 | } 562 | ], 563 | "folder": [ 564 | { 565 | "accountId": "28896164", 566 | "containerId": "1664526", 567 | "folderId": "4", 568 | "name": "Angulartics", 569 | "fingerprint": "1445862705449" 570 | } 571 | ] 572 | } 573 | } -------------------------------------------------------------------------------- /import/universal-analytics-import.json: -------------------------------------------------------------------------------- 1 | { 2 | "exportFormatVersion": 2, 3 | "exportTime": "2018-02-23 15:28:01", 4 | "containerVersion": { 5 | "path": "accounts/28896164/containers/7267080/versions/0", 6 | "accountId": "28896164", 7 | "containerId": "7267080", 8 | "containerVersionId": "0", 9 | "container": { 10 | "path": "accounts/28896164/containers/7267080", 11 | "accountId": "28896164", 12 | "containerId": "7267080", 13 | "name": "Angulartics Universal", 14 | "publicId": "GTM-5RWST4G", 15 | "usageContext": [ 16 | "WEB" 17 | ], 18 | "fingerprint": "1519399674369", 19 | "tagManagerUrl": "https://tagmanager.google.com/#/container/accounts/28896164/containers/7267080/workspaces?apiLink=container" 20 | }, 21 | "tag": [ 22 | { 23 | "accountId": "28896164", 24 | "containerId": "7267080", 25 | "tagId": "3", 26 | "name": "Angulartics Events", 27 | "type": "ua", 28 | "parameter": [ 29 | { 30 | "type": "TEMPLATE", 31 | "key": "nonInteraction", 32 | "value": "{{angulartics event interaction type}}" 33 | }, 34 | { 35 | "type": "BOOLEAN", 36 | "key": "overrideGaSettings", 37 | "value": "false" 38 | }, 39 | { 40 | "type": "TEMPLATE", 41 | "key": "eventValue", 42 | "value": "{{angulartics event value}}" 43 | }, 44 | { 45 | "type": "TEMPLATE", 46 | "key": "eventCategory", 47 | "value": "{{angulartics event category}}" 48 | }, 49 | { 50 | "type": "TEMPLATE", 51 | "key": "trackType", 52 | "value": "TRACK_EVENT" 53 | }, 54 | { 55 | "type": "TEMPLATE", 56 | "key": "gaSettings", 57 | "value": "{{angulartics settings}}" 58 | }, 59 | { 60 | "type": "TEMPLATE", 61 | "key": "eventAction", 62 | "value": "{{angulartics event action}}" 63 | }, 64 | { 65 | "type": "TEMPLATE", 66 | "key": "eventLabel", 67 | "value": "{{angulartics event label}}" 68 | } 69 | ], 70 | "fingerprint": "1519398973494", 71 | "firingTriggerId": [ 72 | "6" 73 | ], 74 | "parentFolderId": "5", 75 | "tagFiringOption": "ONCE_PER_EVENT" 76 | }, 77 | { 78 | "accountId": "28896164", 79 | "containerId": "7267080", 80 | "tagId": "4", 81 | "name": "Angulartics Pageviews", 82 | "type": "ua", 83 | "parameter": [ 84 | { 85 | "type": "BOOLEAN", 86 | "key": "overrideGaSettings", 87 | "value": "false" 88 | }, 89 | { 90 | "type": "TEMPLATE", 91 | "key": "trackType", 92 | "value": "TRACK_PAGEVIEW" 93 | }, 94 | { 95 | "type": "TEMPLATE", 96 | "key": "gaSettings", 97 | "value": "{{angulartics settings}}" 98 | } 99 | ], 100 | "fingerprint": "1519398965671", 101 | "firingTriggerId": [ 102 | "7" 103 | ], 104 | "parentFolderId": "5", 105 | "tagFiringOption": "ONCE_PER_EVENT" 106 | } 107 | ], 108 | "trigger": [ 109 | { 110 | "accountId": "28896164", 111 | "containerId": "7267080", 112 | "triggerId": "6", 113 | "name": "Angulartics events", 114 | "type": "CUSTOM_EVENT", 115 | "customEventFilter": [ 116 | { 117 | "type": "EQUALS", 118 | "parameter": [ 119 | { 120 | "type": "TEMPLATE", 121 | "key": "arg0", 122 | "value": "{{_event}}" 123 | }, 124 | { 125 | "type": "TEMPLATE", 126 | "key": "arg1", 127 | "value": "interaction" 128 | } 129 | ] 130 | } 131 | ], 132 | "fingerprint": "1500916446845", 133 | "parentFolderId": "5" 134 | }, 135 | { 136 | "accountId": "28896164", 137 | "containerId": "7267080", 138 | "triggerId": "7", 139 | "name": "Angulartics pageviews", 140 | "type": "CUSTOM_EVENT", 141 | "customEventFilter": [ 142 | { 143 | "type": "EQUALS", 144 | "parameter": [ 145 | { 146 | "type": "TEMPLATE", 147 | "key": "arg0", 148 | "value": "{{_event}}" 149 | }, 150 | { 151 | "type": "TEMPLATE", 152 | "key": "arg1", 153 | "value": "content-view" 154 | } 155 | ] 156 | } 157 | ], 158 | "fingerprint": "1500916446845", 159 | "parentFolderId": "5" 160 | } 161 | ], 162 | "variable": [ 163 | { 164 | "accountId": "28896164", 165 | "containerId": "7267080", 166 | "variableId": "1", 167 | "name": "Google Analytics Tracking ID - Angulartics", 168 | "type": "c", 169 | "parameter": [ 170 | { 171 | "type": "TEMPLATE", 172 | "key": "value", 173 | "value": "UA-XXXXXX-YY" 174 | } 175 | ], 176 | "fingerprint": "1500916446846", 177 | "parentFolderId": "5" 178 | }, 179 | { 180 | "accountId": "28896164", 181 | "containerId": "7267080", 182 | "variableId": "13", 183 | "name": "angulartics custom task campaign info fix", 184 | "type": "jsm", 185 | "parameter": [ 186 | { 187 | "type": "TEMPLATE", 188 | "key": "javascript", 189 | "value": "function () {\n\n var version = 1;\n\n return function(model) {\n\n var referrerCookie = getCookie('_ga-ss');\n var hasCampaignParams = document.location.href.match(/(d|g)clid|utm_source/);\n var referrer = {{Referrer}};\n var uaNum = model.get('trackingId');\n var cache = {};\n var uaNums = [];\n var storedRef,\n storedVersion,\n parts,\n i;\n\n \tif (!referrerCookie && !hasCampaignParams) return;\n \n if (referrerCookie) {\n \n parts = referrerCookie.split('|');\n storedVersion = Number(parts[0]);\n\n if (version === storedVersion) {\n\n uaNums = parts[1].length ? parts[1].split(',') : uaNums\n storedRef = decodeURIComponent(parts[2]);\n\n for (i = 0; i < uaNums.length; i++) cache[uaNums[i]] = true;\n\n }\n\n if (!referrer) return setRefCookie(uaNums, storedRef);\n\n }\n\n if (storedRef === referrer) {\n\n if (cache[uaNum]) {\n model.set('referrer', null);\n } else {\n uaNums.push(uaNum);\n }\n\n } else {\n\n // New referrer and no campaign params, we can dump the cookie entirely\n if (!hasCampaignParams) {\n\n document.cookie = '_ga-ss=; Expires=Thu, 01 Jan 1970 00:00:01 GMT; Path=/'; \n \n } else {\n\n uaNums = [uaNum];\n setRefCookie(uaNums, referrer)\n \n }\n \n }\n\n };\n\n function setRefCookie(uaNums, referrer) {\n\n document.cookie = \"_ga-ss=\" +\n [version, uaNums.join(), encodeURIComponent(referrer)].join('|') +\n \"; Expires=\" + new Date(+new Date() + 1000 * 60 * 30).toGMTString() +\n \"; Path=/\";\n \n }\n\n function getCookie(cookieName) {\n \n cookieName = \"; \" + cookieName + \"=\";\n var cookieStr = \"; \" + document.cookie;\n \n if (cookieStr.indexOf(cookieName) > -1) {\n \n return cookieStr.split(cookieName)[1].split(';')[0];\n \n }\n \n }\n \n}" 190 | } 191 | ], 192 | "fingerprint": "1519398894122" 193 | }, 194 | { 195 | "accountId": "28896164", 196 | "containerId": "7267080", 197 | "variableId": "2", 198 | "name": "angulartics event action", 199 | "type": "v", 200 | "parameter": [ 201 | { 202 | "type": "BOOLEAN", 203 | "key": "setDefaultValue", 204 | "value": "false" 205 | }, 206 | { 207 | "type": "INTEGER", 208 | "key": "dataLayerVersion", 209 | "value": "2" 210 | }, 211 | { 212 | "type": "TEMPLATE", 213 | "key": "name", 214 | "value": "action" 215 | } 216 | ], 217 | "fingerprint": "1500916446847", 218 | "parentFolderId": "5" 219 | }, 220 | { 221 | "accountId": "28896164", 222 | "containerId": "7267080", 223 | "variableId": "3", 224 | "name": "angulartics event category", 225 | "type": "v", 226 | "parameter": [ 227 | { 228 | "type": "BOOLEAN", 229 | "key": "setDefaultValue", 230 | "value": "false" 231 | }, 232 | { 233 | "type": "INTEGER", 234 | "key": "dataLayerVersion", 235 | "value": "2" 236 | }, 237 | { 238 | "type": "TEMPLATE", 239 | "key": "name", 240 | "value": "target" 241 | } 242 | ], 243 | "fingerprint": "1500916446847", 244 | "parentFolderId": "5" 245 | }, 246 | { 247 | "accountId": "28896164", 248 | "containerId": "7267080", 249 | "variableId": "4", 250 | "name": "angulartics event interaction type", 251 | "type": "v", 252 | "parameter": [ 253 | { 254 | "type": "BOOLEAN", 255 | "key": "setDefaultValue", 256 | "value": "false" 257 | }, 258 | { 259 | "type": "INTEGER", 260 | "key": "dataLayerVersion", 261 | "value": "2" 262 | }, 263 | { 264 | "type": "TEMPLATE", 265 | "key": "name", 266 | "value": "interaction-type" 267 | } 268 | ], 269 | "fingerprint": "1500916446848", 270 | "parentFolderId": "5" 271 | }, 272 | { 273 | "accountId": "28896164", 274 | "containerId": "7267080", 275 | "variableId": "5", 276 | "name": "angulartics event label", 277 | "type": "v", 278 | "parameter": [ 279 | { 280 | "type": "BOOLEAN", 281 | "key": "setDefaultValue", 282 | "value": "false" 283 | }, 284 | { 285 | "type": "INTEGER", 286 | "key": "dataLayerVersion", 287 | "value": "2" 288 | }, 289 | { 290 | "type": "TEMPLATE", 291 | "key": "name", 292 | "value": "target-properties" 293 | } 294 | ], 295 | "fingerprint": "1500916446849", 296 | "parentFolderId": "5" 297 | }, 298 | { 299 | "accountId": "28896164", 300 | "containerId": "7267080", 301 | "variableId": "6", 302 | "name": "angulartics event value", 303 | "type": "v", 304 | "parameter": [ 305 | { 306 | "type": "BOOLEAN", 307 | "key": "setDefaultValue", 308 | "value": "false" 309 | }, 310 | { 311 | "type": "INTEGER", 312 | "key": "dataLayerVersion", 313 | "value": "2" 314 | }, 315 | { 316 | "type": "TEMPLATE", 317 | "key": "name", 318 | "value": "value" 319 | } 320 | ], 321 | "fingerprint": "1500916446850", 322 | "parentFolderId": "5" 323 | }, 324 | { 325 | "accountId": "28896164", 326 | "containerId": "7267080", 327 | "variableId": "7", 328 | "name": "angulartics page path", 329 | "type": "v", 330 | "parameter": [ 331 | { 332 | "type": "BOOLEAN", 333 | "key": "setDefaultValue", 334 | "value": "false" 335 | }, 336 | { 337 | "type": "INTEGER", 338 | "key": "dataLayerVersion", 339 | "value": "2" 340 | }, 341 | { 342 | "type": "TEMPLATE", 343 | "key": "name", 344 | "value": "content-name" 345 | } 346 | ], 347 | "fingerprint": "1500916446851", 348 | "parentFolderId": "5" 349 | }, 350 | { 351 | "accountId": "28896164", 352 | "containerId": "7267080", 353 | "variableId": "12", 354 | "name": "angulartics settings", 355 | "type": "gas", 356 | "parameter": [ 357 | { 358 | "type": "TEMPLATE", 359 | "key": "cookieDomain", 360 | "value": "auto" 361 | }, 362 | { 363 | "type": "BOOLEAN", 364 | "key": "doubleClick", 365 | "value": "false" 366 | }, 367 | { 368 | "type": "BOOLEAN", 369 | "key": "setTrackerName", 370 | "value": "false" 371 | }, 372 | { 373 | "type": "BOOLEAN", 374 | "key": "useDebugVersion", 375 | "value": "false" 376 | }, 377 | { 378 | "type": "LIST", 379 | "key": "fieldsToSet", 380 | "list": [ 381 | { 382 | "type": "MAP", 383 | "map": [ 384 | { 385 | "type": "TEMPLATE", 386 | "key": "fieldName", 387 | "value": "page" 388 | }, 389 | { 390 | "type": "TEMPLATE", 391 | "key": "value", 392 | "value": "{{angulartics page path}}" 393 | } 394 | ] 395 | }, 396 | { 397 | "type": "MAP", 398 | "map": [ 399 | { 400 | "type": "TEMPLATE", 401 | "key": "fieldName", 402 | "value": "userId" 403 | }, 404 | { 405 | "type": "TEMPLATE", 406 | "key": "value", 407 | "value": "{{angulartics user id}}" 408 | } 409 | ] 410 | }, 411 | { 412 | "type": "MAP", 413 | "map": [ 414 | { 415 | "type": "TEMPLATE", 416 | "key": "fieldName", 417 | "value": "customTask" 418 | }, 419 | { 420 | "type": "TEMPLATE", 421 | "key": "value", 422 | "value": "{{angulartics custom task campaign info fix}}" 423 | } 424 | ] 425 | }, 426 | { 427 | "type": "MAP", 428 | "map": [ 429 | { 430 | "type": "TEMPLATE", 431 | "key": "fieldName", 432 | "value": "forceSSL" 433 | }, 434 | { 435 | "type": "TEMPLATE", 436 | "key": "value", 437 | "value": "true" 438 | } 439 | ] 440 | } 441 | ] 442 | }, 443 | { 444 | "type": "BOOLEAN", 445 | "key": "useHashAutoLink", 446 | "value": "false" 447 | }, 448 | { 449 | "type": "BOOLEAN", 450 | "key": "decorateFormsAutoLink", 451 | "value": "false" 452 | }, 453 | { 454 | "type": "BOOLEAN", 455 | "key": "enableLinkId", 456 | "value": "false" 457 | }, 458 | { 459 | "type": "BOOLEAN", 460 | "key": "enableEcommerce", 461 | "value": "false" 462 | }, 463 | { 464 | "type": "TEMPLATE", 465 | "key": "trackingId", 466 | "value": "{{Google Analytics Tracking ID - Angulartics}}" 467 | } 468 | ], 469 | "fingerprint": "1519399426577" 470 | }, 471 | { 472 | "accountId": "28896164", 473 | "containerId": "7267080", 474 | "variableId": "8", 475 | "name": "angulartics user id", 476 | "type": "v", 477 | "parameter": [ 478 | { 479 | "type": "BOOLEAN", 480 | "key": "setDefaultValue", 481 | "value": "false" 482 | }, 483 | { 484 | "type": "INTEGER", 485 | "key": "dataLayerVersion", 486 | "value": "2" 487 | }, 488 | { 489 | "type": "TEMPLATE", 490 | "key": "name", 491 | "value": "userId" 492 | } 493 | ], 494 | "fingerprint": "1500916446851" 495 | } 496 | ], 497 | "folder": [ 498 | { 499 | "accountId": "28896164", 500 | "containerId": "7267080", 501 | "folderId": "5", 502 | "name": "Angulartics", 503 | "fingerprint": "1500916446844" 504 | } 505 | ], 506 | "builtInVariable": [ 507 | { 508 | "accountId": "28896164", 509 | "containerId": "7267080", 510 | "type": "REFERRER", 511 | "name": "Referrer" 512 | } 513 | ], 514 | "fingerprint": "0", 515 | "tagManagerUrl": "https://tagmanager.google.com/#/versions/accounts/28896164/containers/7267080/versions/0?apiLink=version" 516 | } 517 | } -------------------------------------------------------------------------------- /lib/angulartics-google-tag-manager.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @license Angulartics v0.19.2 3 | * (c) 2013 Luis Farzati http://luisfarzati.github.io/angulartics 4 | * Google Tag Manager Plugin Contributed by http://github.com/danrowe49 5 | * License: MIT 6 | */ 7 | 8 | (function (angular) { 9 | 'use strict'; 10 | 11 | 12 | /** 13 | * @ngdoc overview 14 | * @name angulartics.google.analytics 15 | * Enables analytics support for Google Tag Manager (http://google.com/tagmanager) 16 | */ 17 | 18 | angular.module('angulartics.google.tagmanager', ['angulartics']) 19 | .config(['$analyticsProvider', function ($analyticsProvider) { 20 | 21 | $analyticsProvider.settings.ga = { 22 | userId: null 23 | }; 24 | 25 | /** 26 | * Send content views to the dataLayer 27 | * 28 | * @param {string} path Required 'content name' (string) describes the content loaded 29 | */ 30 | 31 | $analyticsProvider.registerPageTrack(function (path) { 32 | var dataLayer = window.dataLayer = window.dataLayer || []; 33 | dataLayer.push({ 34 | 'event': 'content-view', 35 | 'content-name': path, 36 | 'userId': $analyticsProvider.settings.ga.userId 37 | }); 38 | }); 39 | 40 | /** 41 | * Send interactions to the dataLayer, i.e. for event tracking in Google Analytics 42 | * @name eventTrack 43 | * 44 | * @param {string} action Required 'action' (string) associated with the event 45 | * @param {object} properties Comprised of the mandatory field 'category' (string) and optional fields 'label' (string), 'value' (integer) and 'noninteraction' (boolean) 46 | */ 47 | 48 | $analyticsProvider.registerEventTrack(eventTrack); 49 | 50 | function eventTrack(action, properties) { 51 | var dataLayer = window.dataLayer = window.dataLayer || []; 52 | properties = properties || {}; 53 | dataLayer.push({ 54 | 'event': properties.event || 'interaction', 55 | 'target': properties.category, 56 | 'action': action, 57 | 'target-properties': properties.label, 58 | 'value': properties.value, 59 | 'interaction-type': properties.noninteraction, 60 | 'userId': $analyticsProvider.settings.ga.userId 61 | }); 62 | 63 | } 64 | 65 | /** 66 | * Send exceptions to the dataLayer, reusing the existing Event Tracking tag in GTM 67 | * @name exceptionTrack 68 | * 69 | * @param {object} error An Error object to track: error.toString() used for event 'action', error.stack used for event 'label'. 70 | * @param {object} cause The cause of the error given from $exceptionHandler, not used 71 | */ 72 | 73 | $analyticsProvider.registerExceptionTrack(function(error, cause) { 74 | 75 | eventTrack(error.toString(), { 76 | 'category': 'Exceptions', 77 | 'label': error.stack 78 | }); 79 | 80 | }); 81 | 82 | /** 83 | * Set userId for use with Universal Analytics User ID feature 84 | * @name setUsername 85 | * 86 | * @param {string} userId Required 'userId' value (string) used to identify user cross-device in Google Analytics 87 | */ 88 | 89 | $analyticsProvider.registerSetUsername(function (userId) { 90 | $analyticsProvider.settings.ga.userId = userId; 91 | }); 92 | 93 | }]); 94 | 95 | })(angular); 96 | -------------------------------------------------------------------------------- /lib/index.js: -------------------------------------------------------------------------------- 1 | require('./angulartics-google-tag-manager'); 2 | module.exports = 'angulartics.google.tagmanager'; 3 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "angulartics-google-tag-manager", 3 | "version": "0.0.2", 4 | "description": "Google Tag Manager plugin for Angulartics", 5 | "keywords": [ 6 | "google", 7 | "tag manager", 8 | "plugin", 9 | "angular", 10 | "angulartics" 11 | ], 12 | "contributors": [ 13 | "Jared Dickson ", 14 | "Dan Wilkerson " 15 | ], 16 | "main": "lib/index.js", 17 | "scripts": { 18 | "clean": "rm -rf dist", 19 | "prebuild": "npm run clean", 20 | "build": "mkdir -p dist && uglifyjs lib/angulartics-google-tag-manager.js --compress --source-map dist/angulartics-google-tag-manager.min.js.map --source-map-root .. --source-map-url ../dist/angulartics-google-tag-manager.min.js.map -o dist/angulartics-google-tag-manager.min.js" 21 | }, 22 | "repository": { 23 | "type": "git", 24 | "url": "git+https://github.com/angulartics/angulartics-google-tag-manager.git" 25 | }, 26 | "bugs": { 27 | "url": "https://github.com/angulartics/angulartics-google-tag-manager/issues" 28 | }, 29 | "license": "MIT", 30 | "homepage": "https://github.com/angulartics/angulartics-google-tag-manager", 31 | "peerDependencies": { 32 | "angulartics": "^1.0.0" 33 | }, 34 | "devDependencies": { 35 | "uglify-js": "^2.5.0" 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | ## angulartics-google-tag-manager 2 | 3 | [![NPM version][npm-image]][npm-url] [![NPM downloads][npm-downloads-image]][npm-downloads-url] [![Bower version][bower-image]][bower-url] [![Dependencies status][dep-status-image]][dep-status-url] [![MIT license][license-image]][license-url] [![Join the Slack chat][slack-image]][slack-url] 4 | 5 | Google Tag Manager Google Analytics plugin for [Angulartics](https://github.com/angulartics/angulartics). 6 | 7 | ## Install 8 | 9 | First make sure you've read installation and setup instructions for [Angulartics](https://github.com/angulartics/angulartics#install). 10 | 11 | Then you can install this package either with `npm` or with `bower`. 12 | 13 | ### npm 14 | 15 | ```shell 16 | npm install angulartics-google-tag-manager 17 | ``` 18 | 19 | Then add `angulartics.google.tagmanager` as a dependency for your app: 20 | 21 | ```javascript 22 | require('angulartics') 23 | 24 | angular.module('myApp', [ 25 | 'angulartics', 26 | require('angulartics-google-tag-manager') 27 | ]); 28 | ``` 29 | 30 | > Please note that core Angulartics doesn't export the name yet, but it will once we move it into [the new organization](http://github.com/angulartics). 31 | 32 | ### bower 33 | 34 | ```shell 35 | bower install angulartics-google-tag-manager 36 | ``` 37 | 38 | Add the ` 42 | ``` 43 | 44 | Then add `angulartics.google.tagmanager` as a dependency for your app: 45 | 46 | ```javascript 47 | angular.module('myApp', [ 48 | 'angulartics', 49 | 'angulartics.google.tagmanager' 50 | ]); 51 | ``` 52 | 53 | ### Google Tag Manager 54 | 55 | Once you've installed Angulartics into your application, you'll need to perform some configuration in the Google Tag Manager interface. There are two ways to do this; using Google Tag Manager's import functionality, or by manually configuring the required components in Google Tag Manager. To do either, you will need Edit permissions in the Google Tag Manager Container you'd like to use. 56 | 57 | Before beginning configuration, confirm which version of Google Analytics you're using in your application. A simple way to test this is to check the Google Analytics snippet, if there is one. If the code looks like the below, you're using Universal Analytics: 58 | 59 | ```javascript 60 | ga('create', 'UA-XXXXXX-YY', 'auto'); 61 | ga('send', 'pageview'); 62 | ``` 63 | 64 | Alternatively, if the snippet looks like the below, you've got Classic Analytics installed, [which is in the process of being deprecated](https://support.google.com/analytics/answer/4457764?hl=en): 65 | ```javascript 66 | _gaq.push(['_setAccount', 'UA-XXXXXX-YY']); 67 | _gaq.push(['_trackPageview']); 68 | ``` 69 | 70 | > If possible, consider switching to Universal Analytics. If neither appear, or you do not have Google Analytics installed, use the Universal Analytics instructions. 71 | 72 | #### Container Import Installation (recommended) 73 | 74 | 1. Determine which version of Google Analytics your site uses, Classic or Universal, and then locate the corresponding .json file in the /import directory. 75 | 2. In Google Tag Manager, navigate to the **Admin** tab. 76 | 3. Under the **Container** column, select **Import Container**. 77 | 4. Click **Choose Container File** and select the .json file you selected. 78 | 5. Select **Merge** from the radio selector beneath the Choose Container File button. 79 | 6. Select **Rename** from the radio selector that appears beneath the Merge selector. 80 | 7. Click Continue, then Confirm. 81 | 8. Click the **Variables** tab in the left-side navigation. 82 | 9. Scroll to the **User-Defined Variables** section at the bottom of the page and click the **Google Analytics Tracking ID - Angulartics** Variable. 83 | 10. Edit the Value field by clicking on the Variable and replace it with your companies Google Analytics Tracking ID (a.k.a. UA Number). Save your changes. 84 | 85 | #### Manual Installation 86 | 87 | ##### Universal Analytics 88 | 89 | **6 Variables** 90 | 91 | Naming and case must match. 92 | 93 | * Name: **angulartics page path** 94 | * Type: **Data Layer Variable** 95 | * Data Layer Variable Name: **content-name** 96 | * Name: **angulartics event category** 97 | * Type: **Data Layer Variable** 98 | * Data Layer Variable Name: **target** 99 | * Name: **angulartics event action** 100 | * Type: **Data Layer Variable** 101 | * Data Layer Variable Name: **action** 102 | * Name: **angulartics event label** 103 | * Type: **Data Layer Variable** 104 | * Data Layer Variable Name: **target-properties** 105 | * Name: **angulartics event value** 106 | * Macro Type: **Data Layer Variable** 107 | * Data Layer Variable Name: **value** 108 | * Name: **angulartics event interaction type** 109 | * Type: **Data Layer Variable** 110 | * Data Layer Variable Name: **interaction-type** 111 | * (OPTIONAL) **angulartics user id** 112 | * Type: **Data Layer Variable** 113 | * Data Layer Variable Name: **userId** 114 | 115 | **2 Triggers** 116 | 117 | Name and case must match. 118 | 119 | * Name: **Angulartics events** 120 | * Event: **Custom Event** 121 | * Event name: **interaction** 122 | * Name: **Angulartics pageviews** 123 | * Event: **Custom Event** 124 | * Event name: **content-view** 125 | 126 | **2 Tags** 127 | 128 | Name and case must match. 129 | 130 | * Name: **Angulartics Events** 131 | * Product: **Google Analytics** 132 | * Type: **Universal Analytics** 133 | * Tracking ID: **YourGoogleAnalyticsID** 134 | * Track Type: **Event** 135 | * Category: **{{angulartics event category}}** 136 | * Action: **{{angulartics event action}}** 137 | * Label: **{{angulartics event label}}** 138 | * Value: **{{angulartics event value}}** 139 | * Non-Interaction Hit: **{{angulartics event interaction type}}** 140 | * More settings > Fields to Set > name: **page**, value: **{{angulartics page path}}** 141 | * More settings > Fields to Set > name: **cookieDomain**, value: **auto** 142 | * More settings > Fields to Set > name: **userID**, value: **{{angulartics user id}}** 143 | * Fire On: **Angulartics events** 144 | 145 | * Name: **Angulartics Pageviews** 146 | * Product: **Google Analytics** 147 | * Type: **Universal Analytics** 148 | * Tracking ID: **YourGoogleAnalyticsID** 149 | * Track Type: **Page View** 150 | * More settings > Field to Set > name: **page**, value: **{{angulartics page path}}** 151 | * More settings > Field to Set > name: **cookieDomain**, value: **auto** 152 | * More settings > Fields to Set > name: **userID**, value: **{{angulartics user id}}** 153 | * Fire On: **Angulartics pageviews** 154 | 155 | ##### Classic Analytics 156 | **6 Variables** 157 | 158 | Naming and case must match. 159 | 160 | * Name: **angulartics page path** 161 | * Type: **Data Layer Variable** 162 | * Data Layer Variable Name: **content-name** 163 | * Name: **angulartics event category** 164 | * Type: **Data Layer Variable** 165 | * Data Layer Variable Name: **target** 166 | * Name: **angulartics event action** 167 | * Type: **Data Layer Variable** 168 | * Data Layer Variable Name: **action** 169 | * Name: **angulartics event label** 170 | * Type: **Data Layer Variable** 171 | * Data Layer Variable Name: **target-properties** 172 | * Name: **angulartics event value** 173 | * Macro Type: **Data Layer Variable** 174 | * Data Layer Variable Name: **value** 175 | * Name: **angulartics event interaction type** 176 | * Type: **Data Layer Variable** 177 | * Data Layer Variable Name: **interaction-type** 178 | 179 | **2 Triggers** 180 | 181 | Name and case must match. 182 | 183 | * Name: **Angulartics events** 184 | * Event: **Custom Event** 185 | * Event name: **interaction** 186 | * Name: **Angulartics pageviews** 187 | * Event: **Custom Event** 188 | * Event name: **content-view** 189 | 190 | **2 Tags** 191 | 192 | Name and case must match. 193 | 194 | * Name: **Angulartics Events** 195 | * Product: **Google Analytics** 196 | * Type: **Classic Analytics** 197 | * Tracking ID: **YourGoogleAnalyticsID** 198 | * Track Type: **Event** 199 | * Category: **{{angulartics event category}}** 200 | * Action: **{{angulartics event action}}** 201 | * Label: **{{angulartics event label}}** 202 | * Value: **{{angulartics event value}}** 203 | * Non-Interaction Hit: **{{angulartics event interaction type}}** 204 | * More settings > Basic Configuration > Virtual Page Path, value: **angulartics page path** 205 | * More settings > Domains and Directories > Domain Name, value: **YourDomainName** 206 | * Fire On: **Angulartics events** 207 | * Name: **Angulartics Pageviews** 208 | * Product: **Google Analytics** 209 | * Type: **Universal Analytics** 210 | * Tracking ID: **YourGoogleAnalyticsID** 211 | * Track Type: **Page View** 212 | * More settings > Basic Configuration > Virtual Page Path, value: **angulartics page path** 213 | * More settings > Domains and Directories > Domain Name, value: **YourDomainName** 214 | * Fire On: **Angulartics pageviews** 215 | 216 | ## Documentation 217 | 218 | ### User ID Tracking 219 | Universal Analytics, the newest version of Google Analytics, supports tracking users based of an ID that you provide. Typically, this ID is available after a user logs in to your application or service. Providing this ID allows Google Analytics to aggregate across multiple devices and browsers, providing a more holistic view of user interaction with your services. The [documentation](https://support.google.com/analytics/answer/6205850?hl=en&ref_topic=3123660) can provide more insight into the benefits of using the User ID feature. It also stipulates the following: 220 | * The uid parameter must be set on **every hit** sent to Google Analytics 221 | * The uid should be a completely anonymous value, and cannot be a username, or any personally identifiable information (PII); if PII is found in a property, the property will be completely destroyed. **This includes hashed email addresses**. 222 | * The uid parameter should only be set while the user is logged in; once logged out, it should not be set on any hits sent to Google Analytics 223 | 224 | To configure User ID Tracking, set the `$analyticsProvider.settings.ga.userId` property to your provided User ID in the module configuration settings. 225 | 226 | ```javascript 227 | angular.module('myApp', ['angulartics', 'angulartics.google.tagmanager']) 228 | .config(['$analyticsProvider', function ($analyticsProvider) { 229 | 230 | $analyticsProvider.settings.ga = { 231 | userId: myUserIdValue 232 | }; 233 | 234 | ... 235 | }]); 236 | ``` 237 | 238 | Alternatively, you may set your User ID by calling `$analytics.setUsername()` and providing it your userId 239 | 240 | ```javascript 241 | $analytics.setUsername(myUserIdValue); 242 | ``` 243 | 244 | Additional documentation is available on the [Angulartics site](http://angulartics.github.io/). 245 | 246 | ## Development 247 | 248 | ```shell 249 | npm run build 250 | ``` 251 | 252 | ## License 253 | 254 | [MIT](LICENSE) 255 | 256 | [npm-image]: https://img.shields.io/npm/v/angulartics-google-analytics.svg 257 | [npm-url]: https://npmjs.org/package/angulartics-google-analytics 258 | [npm-downloads-image]: https://img.shields.io/npm/dm/angulartics-google-analytics.svg 259 | [npm-downloads-url]: https://npmjs.org/package/angulartics-google-analytics 260 | [bower-image]: https://img.shields.io/bower/v/angulartics-google-analytics.svg 261 | [bower-url]: http://bower.io/search/?q=angulartics-google-analytics 262 | [dep-status-image]: https://img.shields.io/david/angulartics/angulartics-google-analytics.svg 263 | [dep-status-url]: https://david-dm.org/angulartics/angulartics-google-analytics 264 | [license-image]: http://img.shields.io/badge/license-MIT-blue.svg 265 | [license-url]: LICENSE 266 | [slack-image]: https://angulartics.herokuapp.com/badge.svg 267 | [slack-url]: https://angulartics.herokuapp.com 268 | --------------------------------------------------------------------------------