Skip to main content
All CollectionsObservePoint Custom Tag
OP Custom Tag - Open Graph Tags
OP Custom Tag - Open Graph Tags
Luiza Gircoveanu avatar
Written by Luiza Gircoveanu
Updated over 5 months ago

Overview

Social media sites pull from the Open Graph Tags to display content such as images, titles, and subheadings. This custom tag can help optimize traffic and identify pages that are missing Open Graph Tags. It does this by collecting all Open Graph meta tag's outerHTML.

The <meta property="og: ...." other attributes> is pushed into the array of results, dispatched to an array of objects which is sent to the ObservePoint server. The object collected contains an array of results and the amount of meta tags. If there are no Open Graph meta tags, the object returns null.

Under Variable Summary in ObservePoint data select the Open Graph account to access relevant variables.

  • metaOPTagsContent: Shows a list of all URLs and the presence of Open Graph tags.

  • metaTagsLength: Shows the number of Open Graph tags found by page.

  • og:description: Shows the entire Open Graph tag description that social media sites use for each URL.

  • og:image: Shows the image URL for each Open Graph tag that social media sites use for each URL.

  • og:image:height: Shows the image height for each URL in pixels.

  • og:image:width: Shows the image width for each URL in pixels.

  • og:locale: Shows the Open Graph tag's location setting.

  • og:price:amount: Shows the price amount that is associate with the Open Graph tag for each URL.

  • og:price:currency: Shows the currency associated with the Open Graph tag for each URL.

  • og:pubdate: Shows the date of publication associated with the Open Graph tag for each URL.

  • og:site_name: Shows the name of the site as displayed on social media.

  • og:title: Shows the title of the site as displayed on social media.

  • og:type: Shows the type of site the Open Graph tag is deployed on i.e. article, website, video, etc.

  • og:url: Shows the URL associated with each page according to the Open Graph tag.

To capture these details in an Audit or Journey, paste the snippet below into an Execute Action:

function opReqGetAsync(paramObject, acct, callback) {
var baseURL = "https://opreq.observepoint.com/?acct=" + acct;
var opReq = new XMLHttpRequest();
opReq.onreadystatechange = function() {
if (opReq.readyState == 4 && opReq.status == 200) {
callback(opReq.responseText);
}
}
opReq.open("POST", baseURL, true);
opReq.send(JSON.stringify(paramObject));
}
var openGraphTest = function() {
var meta = document.querySelectorAll('meta[property*="og:"]');
var result = [];
var obj = {};
if (meta.length > 0) {
for (var i = meta.length - 1; i >= 0; i--) {
obj[meta[i].getAttribute("property")] = meta[i].getAttribute("content");
};
obj.metaTagsLength = result.length;
opReqGetAsync(obj, 'Open_Graph')
} else {
obj.metaOPTagsContent = null;
opReqGetAsync(obj, ' Open Graph')
}
};
openGraphTest();
Did this answer your question?