I'd set this information via a macro then in the metadata of that page. Go to the page in question, click Properties > Metadata and update the metadata with the fields you want to dynamically display. Here's a post about this methodology.
Typically what we do is set the base metadata at the root of the site, then modify things down in the content tree as needed. For instance if you have a /Products section of your site you can set the metadata of this page to be something like (/Products/Smartphones/Google/Pixel-4-XL) to any of the field names for that page type.
{%ProductName%} by {%CurrentDocument.Parent.DocumentName%}
This would render something like "Pixel 4XL by Google | Website Name". You can do the same in the keywords and description.
Now I get you don't want to set this on every product page so what you can do is set it on the parent page. Assuming you have different page types like custom.brand
and custom.product
you can do a check at that "brand" level like so:
{% if(ClassName.ToLower() == "custom.product") { ProductName + " by " CurrentDocument.Parent.GetValue("BrandName") } else { DocumentName } %} | Website Name
I'd take an approach like this vs. creating a web part. If you need to use the webpart though you can do so using this code:
if (CurrentDocument != null)
{
CMS.UIControls.ContentPage page = this.Page as CMS.UIControls.ContentPage;
if (page != null)
{
page.PageTitle = "Title here";
page.Description = "Description here";
page.KeyWords = "Keywords here";
}
}