# How to set specific social meta tags for specific contribution pages

It would be very useful to be able to set specific social meta tags for specific contribution pages, but I can't seem to find any way to do this (definitely not in CiviCRM, there doesn't seem to be a module to do this in Drupal 7).

The idea would be to set og:image and twitter:image for specific contribution pages, which is fairly important for donation pages. Right now, it doesn't appear that these tags are set at at all; Facebook and Twitter just use the top image on the page.

Two challenges here that I see: 1) I can't add content to a specific contribution page, only to /civicrm/contribute/transact, which adds to all contribution pages. 2) I can't add content in the head of the page.

Is there a clever way to make this work?

If you're willing to write your own drupal module you should be able to do it with drupal_add_html_head in hook_init. I haven't tested that. If not hook_init then maybe in hook_preprocess_html. You would need to parse the url to get the id= parameter and that would tell you which contribution page.

• Would prefer to find a solution that is a little simpler. – Lars SG Dec 19 '19 at 20:12

Block Conditional Visibility by URI Query Parameters deals with the specific contribution page selection issue, but I'm still struggling to insert the meta tags into the head of the page as required.

I've tried just adding it in a block, but Facebook doesn't pick up the tags outside the head, it seems. I've tried javascript like this but that doesn't seem to work.

I wrote an extension ogp that detects some patterns in event/contribution/profile pages, and uses that information to build meta tags.

The README has a bit more details about how the extension works. The idea is to make it "just work", without too much fiddling (i.e. it's fairly limited), but I'm very open to suggestions on how we could improve this.

• Interesting. I think for us, the ideal would be just to add these fields (og:description and og:image) to contribution page settings, event settings, etc. perhaps with a fall back to what you use now. But that's probably a bigger project! – Lars SG Dec 4 '20 at 0:47