1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

JSON-LD Schema Nerds Wanted - Dynamic Schema Insertion

Discussion in 'White Hat SEO' started by Johnny_Tsunami, May 30, 2017.

  1. Johnny_Tsunami

    Johnny_Tsunami Junior Member

    Joined:
    Nov 14, 2016
    Messages:
    181
    Likes Received:
    61
    Occupation:
    Agency Marketing
    Location:
    Surfin' the SERPs
    Howdy

    I have two sites, one is a product website that sells RV. I've created a script through Tag Manager that allows me to dynamically change the schema based on product type, description, cost, etc.. Various things that Schema markup recognizes..

    First off, here's the schema markup I wrote: http://imgur.com/a/VsjaM

    Here's a snippet of the code for that Tag & Trigger, and what the average URL looks like.. (This is for the site that works - the RV site).

    http://imgur.com/a/xI0F8

    Okay... Now here's where I run into issues.. I have a new site, which has a different URL structure and is really annoying... Here are the run downs on that one, notice, on this one, each product ends with the same type of URL, but the 4-digit code at the end changes:

    http://imgur.com/a/gKxHk


    Please help me! What am I missing/What words do I change to make this markup work?

    Thanks again, let me know if I missed something vital for you guys.

    Or if you guys don't even know what schema is.

    EDIT: PM ME for the sites. Don't want them going public.
     
    Last edited: May 30, 2017
  2. Johnny_Tsunami

    Johnny_Tsunami Junior Member

    Joined:
    Nov 14, 2016
    Messages:
    181
    Likes Received:
    61
    Occupation:
    Agency Marketing
    Location:
    Surfin' the SERPs
    So.... "Pro" SEO forum with no technical SEO nerds?!
     
  3. sam3724

    sam3724 Jr. VIP Jr. VIP

    Joined:
    Nov 12, 2012
    Messages:
    1,715
    Likes Received:
    429
    Gender:
    Male
    Occupation:
    Internet marketeer
    Location:
    ***BHW***
    We all are noobs here sir. Probably @Ste Fishkin can explain better in his own uncanny way. :D
     
  4. Ste Fishkin

    Ste Fishkin BANNED BANNED Jr. VIP

    Joined:
    May 14, 2011
    Messages:
    2,058
    Likes Received:
    5,008
    I don't help people who screenshot code instead of using the code tags.
     
    • Thanks Thanks x 3
  5. Johnny_Tsunami

    Johnny_Tsunami Junior Member

    Joined:
    Nov 14, 2016
    Messages:
    181
    Likes Received:
    61
    Occupation:
    Agency Marketing
    Location:
    Surfin' the SERPs
    For my bestest buddy :D
     
  6. Ste Fishkin

    Ste Fishkin BANNED BANNED Jr. VIP

    Joined:
    May 14, 2011
    Messages:
    2,058
    Likes Received:
    5,008
    It's too late I'm not interested.
     
    • Thanks Thanks x 1
  7. littlewebdragon

    littlewebdragon Jr. VIP Jr. VIP

    Joined:
    Dec 30, 2007
    Messages:
    1,708
    Likes Received:
    1,041
    Occupation:
    Occupation
    Location:
    Location
    That's wrong code. :D

    Try this:

    Code:
    <script> (function(){
    var data = {
    "@context": "http://schema.org",
    "@Type": "Product",
    "image": {
    "@Type" : "ImageObject",
    "URL" : {{SCHEMA - Image}}
    },
    "description": {{SCHEMA - Description}},
    "name": {{SCHEMA - Product Title}},
    "width":
    { "@Type": "Distance",
    "Description": {{SCHEMA - Product Width}}
    },
    "offers": {
    "@Type": "Offer",
    "availability": "http://schema.org/InStock",
    "price": {{SCHEMA - Price}},
    "priceCurrency": "USD"
    }
    }
    var script = document.createElement('script');
    script.type = "application/ld+json";
    script.innerHTML = JSON.stringify(data);
    document.getElementsByTagName('head')[0].appendChild(script);
    }) (document);
    </script>
    
    
    For trigger options:
    page view - some page views
    url contains/does not contain:
    url contains: /ProductDetails.asp?ProductCode=
    url does not contain sub-domain of products: /product/motor-home-class-a
     
    • Thanks Thanks x 1