Giter VIP home page Giter VIP logo

schema-org-structured-data's Introduction

Schema.org Structured Data Variable in GTM

This repository is for a variable template for the Google Tag Manager Community Template Gallery

The variable returns a JSON object which represents a Structured Data Graph as per the configuration of the variable in a given GTM container

The variable resembles Yoast's approach to Structured Data: https://developer.yoast.com/features/schema/

Easily extendable due to applied naming conventions and structure


Supported schema types

The following types can be configured, each of which not necessarily exhaustive

  • Organization
  • WebSite
  • WebPage
  • Breadcrumbs
  • Person
  • Product
  • Product Offer
  • Article
  • Images
  • Addresses

Short Example

Assuming you have a corporate blog and want to add some structured data for a typical article page

  • Fill organization data and activate organization
  • Make the organization the WebSite's and Article's publisher
  • Add an address and attach it to the organization
  • Add an image and make it the organization's logo
  • Add WebSite data
  • Add WebPage data
  • Add Article data
  • Add an image and attach it to the Article
  • Add a person and make it the Article's author

As a result you will get something like the following:

Validated Output


Appending the data to a webpage

The variable output needs to be added to the DOM

You can deploy a Custom HTML tag with the following content in order to actually add the structured data to a page:

<script>
  (function() {
    var script = document.createElement('script');
    script.type = "application/ld+json";
    
    // Add the JSON schema structure
    script.innerText = JSON.stringify({{Schema.org - Homepage}});
    
    // Add to DOM
    document.body.appendChild(script);
  })();
</script>

In this example, the variable with the structured data is {{Schema.org - Homepage}}. Make this Custom HTML tag fire on Window Load, Dom Ready, or Page View.


SEO

If you're wondering whether JS-injected structured data is of any use for SEO then the answer is yes. You can read more about it in Google Search's developer documentation.

schema-org-structured-data's People

Contributors

dustinrecko avatar

Stargazers

Zeehan Akhtar avatar David Dennison avatar  avatar Gordon Geraghty avatar Periklis Papanikolaou avatar

Watchers

 avatar

schema-org-structured-data's Issues

GTM template no longer valid

Hey there, thank you for making this template, i've been using it for a number of years!

GTM has unfortunately updated and your template is no long allowed in the community library.
Would you be able to update it so myself and the global community can use it again :D

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.