I'm trying to add a Open Graph tag to a website using the following JavaScript code, I need to add the open graph tags before the closing of the <head>
but the code is not working and the open graph tags are not being added.
var newtext = document.createTextNode(" <meta property='og:type' content='article' /> ");
var x=getElementsByTagName("head")[0]
x.appendChild(newtext);