Javascript – Comment_post function not running with JS

I’m trying to import commenters’ details from WP into Klaviyo using add_action(‘comment_post)’ but can’t get it to work when submitting a comment.

I’ve run the function manually on the test page so it fires correctly and the email is submitted to klaviyo, just doesn’t work when a comment is submitted.

Also changed the script to some standard example like sending an email instead, and it fires correctly.. so it tells me it doesn’t like js?

Is there a way for me to activate this script section when a comment is submitted?

function klaviyo_commenter($comment_ID, $commentdata) {
  <script type="text/javascript">
   var _learnq = _learnq || [];
     _learnq.push(['identify', {
    '$email' : "SAMPLE@EMAIL.COM",
add_action('comment_post', 'klaviyo_commenter', 10, 2 );

Leave a Comment