skip to Main Content

I added dynamic structured data for recipes to my webiste, but the variable for the recipe image is not displayed correctly. The data layer autmatically adds two backslashes in front of every slash of the url. This causes problems with the rich snippet:

Screenshot DOM variable

Source code

Error in rich results test

rendered HTML in GTM preview

I am no programmer, just an SEO and my skills in HTML are very basic, so I would be very happy if anyone could help me out with that.
Thanks

Julia

2

Answers


  1. It’s called escaping. the slashes are dual-meaning, they act both as a regular character and also as a programing indicator, so when you want to use them as regular char – you have to "escape" the programing meaning by adding a backslash before.

    Login or Signup to reply.
  2. If you want to make sure, that the escaping is removed in the rendered HTML, just create an additional JS var in GTM:

    function removeEscaping() {
      var escapedUrl = {{}}, //your DOM var
          cleanedUrl = escapedUrl.replace('\','');
      return cleanedUrl;
    }
    

    This should do the job…

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search