Reply
Highlighted
Visitor
Posts: 7
Registered: ‎04-20-2018
Accepted Solution

Is it recommendable always try to reduce the number of variables used in the Data Layer?

Hi!

I am defining the Data Layer for a hotel website, one of the data that they want to collect is the search occupancy, and I can do this by sending the rooms / adults / children in one single variable or use three.  Is it better try to use only one or it doesn't matter?

Option A)

search_occupancy

Option B)

search_rooms

search_adults

search_children

 

Thank you

Reply
0 Kudos
Occasional Contributor
Posts: 115
Registered: ‎12-11-2015

Re: Is it recommendable always try to reduce the number of variables used in the Data Layer?

Hi @mike360

It's best practice to keep them separate, exposing data in your data layer at the most granular level, and only grouping them up via extensions when needed by an individual vendor tag.

So in this case, even if you had a requirement for an analytics tag to receive an array in the form [rooms, adults, children], I would personally set them in the data layer individually, and then use a tag scoped extension that would work along the following lines:

b.search_occuancy = [b.search_rooms, b.search_adults, b.search.children]

And then map search_occupancy into the tag. That then gives you the flexibility to play with the logic later, so that if you wanted to separately record a binary flag for "did the search include children" you've got a search_children field you can address directly in a Set Data Values extension to configure a true/false value.

Visitor
Posts: 7
Registered: ‎04-20-2018

Re: Is it recommendable always try to reduce the number of variables used in the Data Layer?

Thank you for your help @UnknownJ

Reply
0 Kudos