Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepend ng- to dataLayer event names to prevent collisions #4

Open
DanWilkerson opened this issue Jan 1, 2016 · 0 comments
Open

Prepend ng- to dataLayer event names to prevent collisions #4

DanWilkerson opened this issue Jan 1, 2016 · 0 comments

Comments

@DanWilkerson
Copy link
Member

Since other code may interoperate with the dataLayer, would anyone object to adding a prepended 'ng-' or 'nglytics-' to the values we're setting for the event property when we push it in? The logic here is pretty much the same as Angular prescribes in their docs for Directive naming - at some future point, Google or a 3rd party may introduce an event that would collide with a too-generic event name.

E.g.:

dataLayer.push({
  'event': 'interaction',
  ...
});

becomes

dataLayer.push({
  'event': 'nglytics-interaction',
  ...
});

One further step we could take would be to namespace all of our properties, too, like so:

dataLayer.push({
  'event': 'nglytics-interaction',
  'nglyticsVals': {
    'target': 'CATEGORY_NAME',
    'action': 'ACTION_NAME'
    ...
  }
});

Again, the idea being that someone else could set the 'label' property, which could be accidentally inherited by an event angulartics fires later on down the line, leading to some confusing and hard to debug issues.

Any objections? I can put together a PR with fixed docs etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant