Point to api subdomain for the js. Remove the script tags from the template tag.
Print out the error if logging fails. Add GA.