ember-tracker
Advanced tools
Comparing version 0.3.0 to 0.4.0
@@ -33,4 +33,3 @@ import Ember from 'ember'; | ||
let page = this.get('url'), | ||
title = getTitle(route); | ||
const applyArgs = [this.get('url'), getTitle(route)]; | ||
@@ -41,8 +40,15 @@ if (typeOf(route.beforeAnalyticsPageview) === 'function') { | ||
if (changes) { | ||
page = changes.page || page; | ||
title = changes.title || title; | ||
if (changes.page) { | ||
applyArgs[0] = changes.page; | ||
} | ||
if (changes.title) { | ||
applyArgs[1] = changes.title; | ||
} | ||
if (changes.options) { | ||
applyArgs[2] = changes.options; | ||
} | ||
} | ||
} | ||
ga.pageview(page, title); | ||
ga.pageview.apply(ga, applyArgs); | ||
}), | ||
@@ -49,0 +55,0 @@ |
10
index.js
@@ -41,3 +41,5 @@ /* eslint-env node */ | ||
const trackingId = analyticsSettings.trackingId, | ||
onload = Boolean(analyticsSettings.onload); | ||
onload = Boolean(analyticsSettings.onload), | ||
options = analyticsSettings.createOptions, | ||
createOptions = options ? `,${JSON.stringify(options)}` : ''; | ||
@@ -49,9 +51,9 @@ text = `Including Google Analytics (${trackingId}`; | ||
if (onload) { | ||
script += 'window.addEventListener("load",function(){'; | ||
script += 'window.addEventListener("load",function et_RmGa(){'; | ||
} | ||
script += `(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');ga('create','${trackingId}','auto');`; | ||
script += `(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');ga('create','${trackingId}'${createOptions});`; | ||
if (onload) { | ||
script += "});"; | ||
script += "window.removeEventListener('load',et_RmGa,false);},false);"; | ||
} | ||
@@ -58,0 +60,0 @@ |
{ | ||
"name": "ember-tracker", | ||
"version": "0.3.0", | ||
"version": "0.4.0", | ||
"description": "Easily add Google Analytics page and event tracking to your Ember JS Application.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -70,5 +70,4 @@ # ember-tracker | ||
* `onload` (boolean) - Lazy loads Google Analytics after the `window.onload` function fires. | ||
* `createOptions` (object) - This will get `JSON.stringify` encoded and passed to the create object as the last parameter. | ||
These options allow you to ensure your events are being fired. | ||
## Configuring Tealium IQ | ||
@@ -75,0 +74,0 @@ |
AI-detected possible typosquat
Supply chain riskAI has identified this package as a potential typosquat of a more popular package. This suggests that the package may be intentionally mimicking another package's name, description, or other metadata.
Found 1 instance in 1 package
23701
544
153
1