Short JavaScript code snippets for custom javascript variables in Google Tag Manager
Inspired by the 30 seconds code project, we decided to create together to the Google Tag Manager community a series of code snippets to help create custom javascript variables in Google Tag Manager.
See the snippets folder to get all scripts or read 1:1 script;
- Convert Google Analytics 4
items
array
in Facebookcontents
pattern; - Convert Google Analytics 4
view_item
event parameter in FacebookviewContent
parameters; - Convert Google Analytics 4
add_to_cart
event parameters in FacebookAddToCart
parameters - Convert Google Analytics 4
purchase
event parameters in FacebookPurchase
parameters - Get Google Analytics
client_id
andsession_id
; - Get Device type based on userAgent
- Check if browser has ad blocker activate
- Captures and converts the data from a submitted form into a javascript object
--- DEPRECATED Google Analytics Universal Analytics are not colleting information since july 2023
- Convert Google Analytics Enhanced Ecommerce data to Google Analytics 4
add_to_cart
event parameters - Convert Google Analytics Enhanced Ecommerce data to Google Analytics 4
view_item
event parameters - Convert Google Analytics Enhanced Ecommerce data to Google Analytics 4
view_item_list
event parameters - Convert Google Analytics Enhanced Ecommerce data to Google Analytics 4
select_item
event parameters - Convert Google Analytics Enhanced Ecommerce data to Google Analytics 4
remove_from_cart
event parameters
Use the snippet template as a reference and create in snippets folder.