Reputation: 91
I am trying to send an event to google analytics whenever the user clicks on the minimize icon on my chat box.
The minimize icon has the id #minimize
, i am simply starting with a a console log hello when clicked, but i can not figure out why it's not working.
The site is: http://2.internetremovals.com.au/ You can see the chat box in the bottom right corner.
My script is:
<script type="text/javascript">
jQuery( "#minimize" ).click(function() {
console.log("hello");
});
</script>
Thanks for any help or suggestions anyone can spare :]
Upvotes: 0
Views: 160
Reputation: 822
You need change you code like this:
jQuery(document).ready(function ($) {
$( "#minimize" ).click(function() {
console.log("hello");
});
});
or try this
$.getScript("https://chatsystem.io/208680", function() {
console.log("hello 1!")
$(document).on('click', "#minimize", function() {
console.log("hello 2!")
});
});
This will bind event after chatbox loaded
This need to ensure that all other stuff loaded before you code begin to work!
UPDATE 1
Added new code
Upvotes: 1