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
accept numbers for setUserId, setEcommerceView, addEcommerceItem, removeEcommerceItem #15131
Conversation
category = ""; | ||
} else if (category instanceof Array) { | ||
category = JSON_PIWIK.stringify(category); | ||
} | ||
|
||
customVariablesPage[5] = ['_pkc', category]; | ||
|
||
if (isDefined(price) && String(price).length) { | ||
if (isDefined(price) && price !== null && price !== false && String(price).length) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW I'm not sure it's on purpose we allow tracking price when there is only category set? Could create another issue for it... maybe it's on purpose ... @mattab
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW String(false).length
would return 5
which is why I added specific check for false and null etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't remember if it's on purpose or not, but seems one should be able to track price even without a category set @tsteur
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, if I see this right you can track just a category, or a category with a price. Not sure why you would track a category with a price but not an SKU or name... sounds to me like price makes only sense when also name or SKU is set?
deepEqual( tracker3.getCustomVariable(3, "page"), false, "All numbers Ecommerce view SKU"); | ||
deepEqual( tracker3.getCustomVariable(4, "page"), false, "All numbers Ecommerce view Name"); | ||
deepEqual( tracker3.getCustomVariable(5, "page"), ["_pkc", ''], "All numbers Ecommerce view Category"); | ||
tracker3.deleteCustomVariables('page'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add a similar test w/ null
s?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@diosmosis I don't think it's needed. Then we would need to start doing this kind of for all methods...
fix #14714
We ran into this issue ourselves actually eg in Matomo for WordPress etc https://github.com/matomo-org/wp-matomo/pull/67/files therefore moved it into 3.13.0 so userId and ecommerce tracking is easier.