To add to what @echocode posted, I would localize the script with the values that are needed rather than include a script tag. The only real difference here is that the script tag is output directly before the script is included. https://codex.wordpress.org/Function_Reference/wp_localize_script