- TLC Home Home
- Discussions Discussions
- Documentation Documentation
- Knowledge Base Knowledge Base
- Education Education
- Blog Blog
- Support Desk Support Desk
Hi,
I have a javascript code extensión with a reference to utag_data for a custom dimensión mapped in the Google Universal Analytics' Tag. But when the value is 0 (or false), the Custom Dimension doesn’t appear at the GA hit.
Create new data source (UDO variable - cd_test4) -> Map the new var to GUA tag dimension4 -> Create Javascript Code Extension:
function test(){ if (something){ return true; }else{ return false; } } b.cd_test4 = test();
when "something" is false, the cd4 doesn't appear at the GA hit, when "something" is true, cd4=1;
(Sorry, I don't find the option to attach an image in this formulary).
Is this behaviour correct or am I missing anything?
01-31-2017 10:45 AM - last edited on 01-31-2017 11:34 AM by kathleen_jo
Hi @vicente_peris,
This is the expected behavior. UDO params should not be falsy (except for an "". That is okay).
If you want to pass in value of 0 then you should convert it to the string "0" that is not a falsy value.
To assert the truthiness of the value in the devtools you can do:
var test = function(value) {
return value ? true:false;
}
test(0) // false
test('0') // true
@vicente_peris Just to carry on from what @Mauricio has said.
In all templates (as long as they are up-to-date) they have been changed to to no longer use the falsey check. They now use this:
if (b[d] !== undefined && b[d] !== "") {
This is basically saying that everything expect undefined
and empty strings
are allowed to be sent through to the tag template.
I think it might be worth raising a support ticket at https://community.tealiumiq.com/t5/custom/page/page-id/support-contact-form
Then we can walk through with you and work out what is happening.
Adrian
02-01-2017 01:26 AM - edited 02-01-2017 01:26 AM
Carrying on to what @adrian_browning is saying:
The problem is not mapping in a falsy value but setting one using the tag template. From the tag template
// from u.all function
// a wrapper for setting values on all trackers (you can initialize more than one using the tiq interface) else if (v) { u.o(tracker_name + e, o, v); }
v here would be the value 0. and would not be set.
Hi Mauricio and Adrian,
Thank you for your quick response.
Best
Copyright All Rights Reserved © 2008-2023