1

I’m currently working on pushing ecommerce and non-ecommerce dataLayer events to GTM + GA4 setup.

My goal is to ensure that when event parameter values are unavailable, they appear as empty cells in GA4 rather than '(not set)'.

For non-ecommerce events, I can modify the event parameters within GTM to handle missing values. For ecommerce events, I rely on the built-in checkbox (send ecommerce data) in GTM to send the ecommerce object, which limits my ability to alter the parameters.

What would you recommend as the best approach to avoid (not set) in my ga4 reports?

Will passing "", undefined or omitting the parameter result in empty cells or show up as '(not set)' in GA4 reports?

If my developers either pass an empty string '', undefined, or completely omit a parameter from the dataLayer when certain values aren’t available. will this work?

For example:

//non ecommerce dataLayer
dataLayer.push({
event: 'custom_event',
user_category: '',        **// Option 1**  
user_location: undefined, **// Option 2**
});


// ecommerce dataLayer where 'item_variant' is omitted
dataLayer.push({
event: 'purchase',
ecommerce: {
transaction_id: 'T12345',
affiliation: '', **//option 1**
value: 199.99,
tax: 15.00,
shipping: 5.00,
currency: 'USD',
items: [
{
item_id: 'SKU_12345',
item_name: 'Wireless Headphones',
affiliation: 'Online Store',
coupon: 'HEADPHONES10',
currency: 'USD',
discount: 10.00,
index: 0,
item_brand: 'SoundMagic',
item_category: '',          **//option 1**
item_category2: undefined , **//option 2**
price: 99.99,
quantity: 1
}]
}
});```

1 Answer 1

0

First of all, you can override the dataLayer ecommerce object with GTM similarly to how you override other dataLayer values, with a custom javascript variable that returns the desired object while consuming the one in the dataLayer.

Secondly, I believe empty strings will result in not sets as well. But even if they didn't, you want to indicate explicitly that the value is "not applicable" or was "not provided" if you don't want it to fall under the generic "not set". Preventing values from dropping under the generic catchall "not set" when possible is considered a good practice. Makes understanding and debugging much easier. Undefined will be cast into string (or a number) and passed over as such, but undefined is another bad choice since it's essentially a generic fallback for JS for anything undefined, and when safe chaining is used, it's not very clear what was undefined in the chain. Still, better than not set for sure.

One of the benefits to overriding the ecommerce object with GTM is that when you need to quickly look up the hardcoded values and conditions for them, you can do it with GTM on your own rather than go ask the front-end to look the values up.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.