Changing og tag based on url params

Viewed 32

this is the parameter I add in my header that let me show a thumbnail in my linkedin messages

<meta property="og:image" content="imageurl">

I would like this image to be dynamic : show different page thumbnail on linkedin messages, by adding query parameters in my url

For example those 2 urls

website/?param=1
website/?param=2

Should modify my og:image property like this

Is it possible to do this?

1 Answers

Edit this doesn't work:

<script>  var link = document.createElement('meta');  link.setAttribute('property', 'og:image');  link.content = imageurl;  document.getElementsByTagName('head')[0].appendChild(link);</script>
Related