There are two dataLayer variables on the page. How do you combine both of them into one single variable so that it can be pushed into analytics ?
dataLayer current format PageName: AIR_SEARCH_PAGE Flow:BOOKING
I want to create another variable which is XYZ and the result to be displayed as BOOKING:AIR_SEARCH_PAGE. How to achieve this ? XYZ:BOOKING:AIR_SEARCH_PAGE
There are several options here:
Combine the strings through GTM. For example, looks like you have the following dataLayer:
dataLayer = [{
'PageName': 'AIR_SEARCH_PAGE',
'Flow': 'BOOKING'
}]
In GTM, you could create a DL variable for 'PageName', and another one for 'Flow', and then when you need to combine them, or add other text around it, you can say:
XYZ: {{Flow}}: {{PageName}}
so this would render as "XYZ: BOOKING: AIR_SEARCH_PAGE"
Use the JS string manipulation and join the strings together and then push to the dataLayer again.
Push a new parameter into the dataLayer that combines the strings for you.
dataLayer.push({
'xyz': 'BOOKING:AIR_SEARCH_PAGE'
})
and then use that new variable through GTM.
I think the first method may be best.