Skip to content
This repository has been archived by the owner on Aug 13, 2024. It is now read-only.

Fix addEnhancedEcommerceImpressionContext picking up the wrong positional arguments #14

Closed
volderette opened this issue May 25, 2020 · 2 comments

Comments

@volderette
Copy link

I was having trouble with the addEnhancedEcommerceImpressionContext as it always was marked as invalid schema. I realized, that the Snowplow library picks up the wrong values of the Datalayer. This seems to be because of the positional arguments the SP library is requiring:

This is an impression datalayer example:

        id: 'U-30-Abo ePaper und M-Plus',
        name: 'U-30-Abo ePaper und M-Plus',
        price: '14.9900',
        brand: 'Mittelbayerische Zeitung',
        category: 'catalog/category/view/s/neukunde-digitale-angebote/id/24/',
        position: 1,
        list: 'Spezial Angebote'

This is what ends up in the Snowplow hit:

id:	U-30-Abo ePaper und M-Plus
name:	U-30-Abo ePaper und M-Plus
list:	Spezial Angebote
brand:	Mittelbayerische Zeitung
category:	catalog/category/view/s/neukunde-digitale-angebote/id/24/
variant:	1
position:	14

Position will end up as variant and part of the price will end up as position.

@volderette
Copy link
Author

I fixed it for my use case. I've added all the fields that can be set regarding to the Snowplow context (https://github.com/snowplow/snowplow/wiki/2-Specific-event-tracking-with-the-Javascript-tracker#3142-addenhancedecommerceimpressioncontext)

  if (getType(obj.impressions) === 'array') {
    obj.impressions.forEach(i => tracker('addEnhancedEcommerceImpressionContext',
                                         i.id,
                 				         i.name,
                                         i.list,
                                         i.brand,
                                         i.category,
                                         i.variant,
                                         i.position,
                                         i.price,
				                         obj.currencyCode));
    action = 'view';
  }

@sahava
Copy link
Contributor

sahava commented May 25, 2020

Thanks! This is fixed in PR #13, so PR #15 can be closed.

@paulboocock paulboocock changed the title addEnhancedEcommerceImpressionContext picks up the wrong positional arguments Fix addEnhancedEcommerceImpressionContext picking up the wrong positional arguments May 26, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants