I have an event snippet for log sign-ups in my ruby on rails project. When a user creates an account (click on sign up) it will load the javascript with the snippet, but I want to load the javascript only when the user makes the account successful
Script:
<script>
function googleAnalytics() {
console.log("google analytics snippet loaded");
}
</script>
html.erb file:
<%= button_tag f.submit t('sign_up'), type: 'button', onclick: 'googleAnalytics()', class: 'btn w-full' %>