Hi! I’m trying to set a self-describing event in Google Tag Manager. I’ve already created the schema for the self-describing event and uploaded it into my Iglu server.
When setting a self-describing event it’s said that we need to configure the “data” parameter to send the data for each field of the self-describing event as described in this document: Self-describing events | Snowplow Documentation.
I tried setting up this parameter through a Google Tag Manager variable using custom JavaScript (shown below).
function() {
var how_did_you_hear_select_element = document.getElementById("how_did_you_hear_element_id");
var country_select_element = document.getElementById("country_element_id");
var state_select_element = document.getElementById("state_element_id");
var first_name = document.querySelector('input[name=names[first_name]]').value || "";
var last_name = document.querySelector('input[name=names[last_name]]').value || "";
var phone = document.querySelector('input[name=phone]').value || "";
var email = document.querySelector('input[name=email]').value || "";
var how_did_you_hear = how_did_you_hear_select_element.options[how_did_you_hear_select_element.selectedIndex].text || "";
var how_did_you_hear_additional_text = document.querySelector('input[name=how_did_you_hear_additional_text]').value || "";
var country_list = country_select_element.options[country_select_element.selectedIndex].text || "";
var state = state_select_element.options[state_select_element.selectedIndex].text || "";
return {
data: {
first_name: first_name,
last_name: last_name,
phone: phone,
email: email,
how_did_you_hear: how_did_you_hear,
how_did_you_hear_additional_text: how_did_you_hear_additional_text,
country_list: country_list,
state: state
}
};
}
I’m capturing form submissions with my self-describing event and the input data from the form. However, when I submit the form from my website, and I look at the enrich server logs, it goes to the bad stream. When looking into the bad output in S3 it shows that it was a ValidationError because the data for each field of the event is missing, so I’m assuming my parameter configuration did not work. I’m unable to find a clear answer on how to set this parameter correctly using Google Tag Manager.
If anyone can help me, I’ll appreciate it! Thanks!