The way I am currently doing this @scott is passing back meta data in the ajax response as well.
Throwing in the Google Analytics line @luke suggested as well!
Example Json object:
{
"meta":{
"title":"This is the default global title of the site pages. | My Website",
"meta":{
"name":{
"keywords":"default,global,comma-separated,keywords",
"description":"This is the default global natural language description of the content on the site pages.",
"dcterms.Identifier":"http:\/\/mywebsite.com\/competition",
"dcterms.Title":"This is the default global title of the site pages.",
"dcterms.Subject":"default,global,comma-separated,keywords",
"dcterms.Date":"2016-06-30",
"dcterms.Description":"This is the default global natural language description of the content on the site pages."
},
"property":{
"og:type":"website",
"og:locale":"en_us",
"og:url":"http:\/\/mywebsite.com\/competition",
"og:title":"This is the default global title of the site pages.",
"og:description":"This is the default global natural language description of the content on the site pages.",
"og:site_name":"My Website"
}
},
"link":{
"rel":{
"canonical":"http:\/\/mywebsite.com\/competition"
}
}
},
}
Then loop through the meta data with JavaScript within you ajax success method. jQuery is used in this example.
Example JS:
$('head').find('title').text(meta.title);
$.each(meta.link, function(k, v){
$.each(v, function(kk, vv){
$('head').find('link[' + k + '="' + kk + '"]').attr('href', vv);
});
});
$.each(meta.meta, function(k, v){
$.each(v, function(kk, vv){
$('meta[' + k + '="' + kk + '"]').attr('content', vv);
});
});