Example Custom JavaScript Variable:
function() {
return 'li_evt_' + Date.now() + '_' + Math.floor(Math.random() * 100000);
}
For e-commerce, combine order ID and timestamp for even stronger uniqueness:
function() {
return 'li_order_' + {{Order ID}} + '_' + Date.now();
}
On the relevant event (e.g. purchase or lead), push the event_id into the data layer so both client and server have access:
Example (placed in your site’s JavaScript or GTM Tag)
window.dataLayer.push({
event: 'purchase',
event_id: 'li_evt_1721456789123_45678',
value: 129.00,
currency: 'EUR'
});
In case you you're using a tag to generate the event, use a custom HTML tag in GTM Web to push this structured event.
Parameter name: event_id
Value: {{DLV – event_id}}
json
{
"event_name": "Purchase",
"event_time": {{Timestamp}},
"event_id": "{{event_id}}",
// ...user_data and custom_data
}