How to Change Meta Tags with JavaScript

0
63

[ad_1]

Making the optimizations we want should come easy for us SEOs, right?

When we need to change on-page elements like title tags, meta descriptions and links, we often turn to our development teams and add our tasks to long lists of urgent jobs. 

It’s too often the case, though—and we’re sure you’ll be nodding along to this next bit—that these tasks aren’t as high-priority as those that are already on the list. 

But what if you could do this yourself? Is it possible to dynamically change meta tags with JavaScript? 

Changing meta tags manually using JavaScript requires some understanding of JavaScript integration with your website. It’s time consuming, but if you only need to make changes every month or so and to a limited number or pages, it can work. 

Another option is a tool like PageImprove that allows you to make those changes in second and is better for when you need to make more than sporadic changes. PageImprove combines a visual editor with a JavaScript plugin to make sure that real-time optimizations actually come easy to us. 

Let’s have a look at whether this is your best option, and if so, how to go about implementing SEO changes on your own.

A meta tag is an element of code used to convey specific information about a page to search engines, such as the <title/> or the <meta name=”description”/> of its contents. These elements collectively represent the metadata of any given page and can influence your search engine rankings and click-through rate from the search engine ranking pages (SERPs). So it’s no wonder that SEOs and content marketers alike have an interest in making changes to them.

Whether you wait months for developer resources to become available or you can’t access your CMS, there are some scenarios in which you’ll need to change the content of meta tags yourself as a matter of relative urgency. You might have new product updates you need to tell customers about, there may be a big Google update, or you might no longer offer a certain service.

To be clear, the best scenario involves you getting your changes made on the backend when you need them made. Changing it with JavaScript is a temporary fix that makes your new content and tags available to search engines and visitors, but does not change the values in the back end of your website.

If you make a change you’d like to be permanent, you still need to implement the changes in the back end, but at least when you use JavaScript to update them, your changes are visible and indexable and there is no delay in making backend changes and no delaying your results. 

How to Change Meta Tag Content Using JavaScript Manually (and When You Should) 

If you decide to tackle this yourself, you’ll need to know how to make hard-coded changes to your site without breaking it. By manipulating the Document Object Model (DOM)—the compilation of HTML, CSS and JavaScript that forms each webpage—you can show search engines what information to index and, therefore, determine what visitors will see.

This involves making direct changes to the code for each page, provided you know how to get to it and, indeed, you actually can.

Let’s say you want to edit the content of the title tag of a particular product page for a bakery. Perhaps your chocolate fudge cake has been spruced up to make it even more appealing.

  1. Find out how to add the JavaScript code to your website. The method will vary by platform.
  2. You need to add the snippet of JavaScript code, that will make the change to the title tag on the particular page. The needed code will vary by platform.
  3. Repeat for all pages requiring title changes.

It’s an approach that gives you some control over your meta titles (and descriptions), since you can use almost any attribute values you like to optimize each page, but it can be a lot of manual work (not to mention the steep learning curve). 

If writing custom JavaScript code doesn’t appeal to you, there is another option.

How to Change Meta Tags the Easy Way with PageImprove

Spending time looking around for an easy way to change your meta tags with JavaScript is probably not the best use of your time. On the other hand, installing a simple browser extension probably is…

PageImprove handles all the manipulation of the DOM for you, so you can quickly make the on-page SEO improvements you need and get faster SEO results for your clients.

There’s no coding experience required—all you need to do to make real-time optimizations is install the browser extension and add the 5kb JavaScript snippet to your site and you’re good to go.

You or your development team add the snippet manually to the <head>. Make sure it’s installed on every page so your changes can be published by the tool (otherwise, they’ll only be saved as drafts).

Tg0uRBTHwicmdhu2noXEj-DrgVHjEn3F8tMRGxVB4W8p714xpfQP2fM_mkGonLf3W7RBP3gtJmMOzDPzQEGMPXYmF9MrYMEGolkiucHv_Xxn2y-fLOadwpM1zbv18J38xQZxqN-U_o2R0KvYqC-DQkpl3NdoK5agTmplsJqP-PDCygHUJANsK3t0Ow

Once that’s done, you can start making the edits you want to your meta tags using the intuitive, visual editor, without fear of making permanent changes to your site’s code. Simply go to the page you want to optimize, select ‘Basic tags’ and type in your text using the handy character counters to guide you.

LFJ6FWS8f_MhKs9Ez2gZ8zRkKI-bhp3giObKySBW3_DmrfbMpHF38zDF3EegnqfRWRNcyvCiumixXWKBU4xBdcWXQCckJTmMHL0BwKWeBcuBXdxYKL4TdKbBXdPm6S5ZHgaVGTbt61optmUKFmbCVi67r4-WRT18Hldh0KF6YStMk8XnICmWnOCCTQ

You can then publish the changes to make them visible to both bots and visitors and start tracking your search performance afterwards. If the changes aren’t what you wanted, don’t worry—they’re far from permanent. With a single click, you can revert back to the way things were before.

17t40N9lXlxUP7KLZnI7P62dTPtYNL50Nz4_HdzmNfz3OzU5hiwH72YwdkgVMEsyWHnPzO_Tjwawa-gAiu3Vks-UtB0eyVFRRK36tohJFDOBaxTNnH6yRffc8buaIMlDW_wbIcO5_4niYFyVkPRjVwbnaTAWp4iShGlT6XSjxoKEW4PwHoDNPou5Rw

If the changes to your meta tags are improving the search performance of the pages in question and you want to make them permanent, you can simply export a list of them in a CSV file to send to your developers.

sVi-n60e-Q1fQ2JG-nh6fKO4NBiWG3pGfXlMT5JzlBBK6jkIanszwkqi_Su8q799GuGCMU_x-ZVL-gQ7W-yU-WRpivXVJiNBXKmAGNcx8-ck4q2-0f_5VW4l7NgXiUSTxdb1tCE9cV51OSax4LzTimoOvuXoZHMxtcZW3VrrmGFWjkwdGnlsiRVR4Q

It’s a great way to ensure SEOs and developers can work together instead of trampling over each other’s priorities, and it’s a great way to secure better SEO outcomes for the sites you’re working on out there.

Are you ready to try PageImprove today to deliver faster SEO results? Click the link to get started for free. 

[ad_2]