Sprout SEO 3 with Craft Tags ENVIRONMENT: Craft 2, Sprout SEO 3.4.2, Bob Olde Hampsink's "Tag Manager" plugin.

The site has a bunch of articles organized by category and tags, and I've got a template for showing articles by tag (ex: https://www.therapyinphiladelphia.com/tips/tag/employment/).

In Sprout SEO I've "Enabled Meta Details fields" and attached them to Craft's TAGS using the Tag Manager plugin. This allows me to insert custom metadata for each TAG just like I would on a normal Craft entry.

So in theory the {% sproutseo 'optimize' %} template tag on my "articles by tag" template should pick up the custom values entered into the Sprout SEO meta details fields for the tag... just like it would for a normal entry.

However it's not picking up anything, it just reverts to the Globals set under Sprout SEO's settings.

To debug I've done a couple of things:


Under Sprout SEO > Settings > Advanced > Enabled custom metadata variable (giving it the name metadata), and
turned on Craft's dev mode and echoed {{ dump(metadata) }} into the template.


The output of {{ dump(metadata) }} shows the Globals set under Sprout SEO's settings and not the custom metadata entered into the Tag Manager for the selected tag.

I've also tried using the {% do craft.sproutSeo.meta() %} function to manually override the automatic output of the {% sproutseo 'optimize' %} template tag.

{#
 # ARTICLES BY TAG TEMPLATE
 #}

{% sproutseo 'optimize' %}

    {% do craft.sproutSeo.meta({ 
      section: 'Self Help Tips',
      title: tag.title,
      description: metadata.metaDescription|striptags|slice(0, 150),
      canonical: craft.request.url,
      ogTitle: tag.title,
      ogType: 'article',
      ogUrl: craft.request.url,
      ogImage: metaImage.url(),
      ogImageWidth: metaImage.width,
      ogImageHeight: metaImage.height,
      ogImageType: metaImage.mimeType,
      ogSiteName: siteName,
      ogDescription: metadata.description,
      twitterCard: 'summary',
      twitterSite: '@twitteruser',
      twitterCreator: '@twitteruser',
      twitterTitle: tag.title,
      twitterDescription: meta.search.description,
      twitterUrl: craft.request.url,
      twitterImage: metaImage.url()
    }) %}


This works if I enter hardcoded strings in, but the metadata variable in the template doesn't pick up the custom metadata entered for the tag.

Is this a bug? Is the Sprout SEO plugin only set up to work with ENTRIES, and not TAGS?
For any Elements that do not have URLs, like Tags or Users, you'll need to tell Sprout SEO what metadata to use.

Also, be sure that the do craft.sproutSeo.meta tag comes before the {% sproutseo 'optimize' %} tag. The do tag prepares the metadata for the optimize tag to process:

{% do craft.sproutSeo.meta({ 
  section: 'Self Help Tips',
  title: tag.title,
  description: metadata.metaDescription|striptags|slice(0, 150),
  canonical: craft.request.url,
  ogTitle: tag.title,
  ogType: 'article',
  ogUrl: craft.request.url,
  ogImage: metaImage.url(),
  ogImageWidth: metaImage.width,
  ogImageHeight: metaImage.height,
  ogImageType: metaImage.mimeType,
  ogSiteName: siteName,
  ogDescription: metadata.description,
  twitterCard: 'summary',
  twitterSite: '@twitteruser',
  twitterCreator: '@twitteruser',
  twitterTitle: tag.title,
  twitterDescription: meta.search.description,
  twitterUrl: craft.request.url,
  twitterImage: metaImage.url()
}) %}

{% sproutseo 'optimize' %}


We do have on our list to simplify this scenario and allow you to add an Element Metadata field to the field layout and just pass the elementId.

{% do craft.sproutSeo.meta({ 
      elementId: 123
}) %}

{% sproutseo 'optimize' %}