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

Using Enhanced Ecommerce #19

Open
harm-less opened this issue Feb 9, 2017 · 1 comment
Open

Using Enhanced Ecommerce #19

harm-less opened this issue Feb 9, 2017 · 1 comment

Comments

@harm-less
Copy link

harm-less commented Feb 9, 2017

Hello,

Great library. I've been using Angulartics for some years already in combination with the GTM plugin.

I just discovered this repo as I guess I should use this from now on (from what I understand from this issue: #13). But even now I don't think I can use GTM Enhanced Ecommerce well with this package. The reason for this is that they specifically ask for a node/variable called ecommerce in the root of the pushed object. The way I go about it right now is to override the registerEventTrack method with this:

this.registerEventTrack = function(action, properties) {
	properties = properties || {};

	var knownProperties = ['event', 'category', 'label', 'noninteraction'];
	var unknownProperties = _.pick(angular.copy(properties), function(value, key) {
		return !_.contains(knownProperties, key);
	});

	// merge the normal object and perhaps custom values. Afterwards, get rit of all empty values
	that.push(_.pick(_.extend({
		event: properties.event || 'interaction',
		target: properties.category,
		action: action || undefined,
		'target-properties': properties.label,
		'interaction-type': properties.noninteraction
	}, unknownProperties), function(key) {
		return !(key === null || angular.isUndefined(key));
	}));
};

It allows me to add custom root nodes (more than just ecommerce) while keeping the original functionality from this plugin intact. It works, but it isn't handy/dry.

Is Enhanced Ecommerce support something which is ever considered? If not, I'd love to make a pr so it's supported in the provider.

@harm-less
Copy link
Author

Actually, I've a whole setup that support a few of the Enhanced Ecommerce methods like impressions, clicks and a purchase (as that's only what we need at the moment).

One of the features is that the impressions are only triggered and pushed when they're in the viewport which I think is kind of neat.

Anyway, I have some plans of making this into a fully fully fledged plugin for Angulartics. Let me know if you're interested in this too because perhaps we can collaborate on this.

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

No branches or pull requests

1 participant