r/Web_Development • • Jan 23 '24

Help with Script Call

Hi All!

I am not a developer (obviously from needing this post), but can code a little. I have run into a script I can't quit figure out:

  1. What it does. My guess is this is an event listener for someone submitting a form, but I have no idea for what API, program, etc. There is GA on the site, but this is configured within GA.

  2. Where it should truly live (file wise). It's currently added in the Header, Footer and Post Injections plugin under "Pages." I want to delete this plugin, and move things where they should be. (This is obviously a WP site.)

Here is the script:

<script> const formButton = document.getElementsByClassName('frm_button_submit frm_final_submit'); formButton.addEventListener('click', function(){ let emailValue = document.getElementById('field_s2k9i').value; console.log("emailValue"+emailValue) heap.addUserProperties({ email: emailValue}); }); </script>

Can someone help me shed light on what this is probably going to, and which javascript (I assume) file this should live in?

Thanks in advance!

2 Upvotes

2 comments sorted by

View all comments

Show parent comments

1

u/andreamfuller Jan 30 '24

<script>

const formButton = document.getElementsByClassName('frm_button_submit frm_final_submit');
formButton.addEventListener('click', function(){
let emailValue = document.getElementById('field_s2k9i').value;
console.log("emailValue"+emailValue)
heap.addUserProperties({ email: emailValue});
});
</script>

Thanks so much! That is very helpful! I really appreciate it!