<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en"><generator uri="https://jekyllrb.com/" version="3.8.3">Jekyll</generator><link href="https://dannyrb.com/feed.xml" rel="self" type="application/atom+xml" /><link href="https://dannyrb.com/" rel="alternate" type="text/html" hreflang="en" /><updated>2019-03-08T01:34:03+00:00</updated><id>https://dannyrb.com/</id><title type="html">Dannyrb</title><subtitle>💻 Code, 🧠 Thoughts, and 📚 Me I owe a lot to the knowledge others have shared; this is my small contribution.
</subtitle><author><name>Danny Brown</name><email>danny.ri.brown@gmail.com</email></author><entry><title type="html">Cornerstone.js: A New Look</title><link href="https://dannyrb.com/blog/2019-02-25-cornerstone-js-a-new-look/" rel="alternate" type="text/html" title="Cornerstone.js: A New Look" /><published>2019-02-25T00:00:00+00:00</published><updated>2019-02-25T00:00:00+00:00</updated><id>https://dannyrb.com/blog/cornerstone-js-a-new-look</id><content type="html" xml:base="https://dannyrb.com/blog/2019-02-25-cornerstone-js-a-new-look/">&lt;p&gt;For those not aware, I became a core team member of &lt;a href=&quot;https://cornerstonejs.org/&quot;&gt;Cornerstone.js&lt;/a&gt; in late 2017. Since then, I’ve actively worked to improve the cornerstone.js libaries and grow its community.&lt;/p&gt;

&lt;p&gt;Today, as a part of those efforts, we have developed a style guide and adopted a new logo. Here’s a piece on how we found our way.&lt;/p&gt;

&lt;!--more--&gt;

&lt;h2 id=&quot;from-one-to-many&quot;&gt;From One to Many&lt;/h2&gt;

&lt;p&gt;From early 2014 to late 2017 Cornerstone’s face was &lt;a href=&quot;https://github.com/chafey&quot;&gt;Chris Hafey&lt;/a&gt;’s face. The Cornerstone repositories were owned by his personal GitHub account, and most major changes (unofficially) required his blessing. By late 2017, the bulk of Cornerstone’s maintenance efforts had fallen squarely on the shoulders of &lt;a href=&quot;http://ohif.org/&quot;&gt;OHIF&lt;/a&gt;’s &lt;a href=&quot;https://github.com/swederik&quot;&gt;Erik Ziegler&lt;/a&gt;. Ziegler worked dilligently to cultivate academic and commercial collaborators (including me 👋).&lt;/p&gt;

&lt;p&gt;Together, having identified community growth as a top priority, we made the following changes:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Creation of GitHub Organization “cornerstonejs”&lt;/li&gt;
  &lt;li&gt;Creation of NPM Organization “cornerstonejs”&lt;/li&gt;
  &lt;li&gt;Creation of Slack Group for active contributor discussions&lt;/li&gt;
  &lt;li&gt;Purchase of &lt;a href=&quot;https://cornerstonejs.org/&quot;&gt;cornerstonejs.org&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Founding of “Core Team” charged with charting Cornerstone.js’s path&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Branding the Cornerstone libraries Hafey created as the “Cornerstone.js Organization” was an important step. It created a shift in thinking from Cornerstone.js: “the work of one or two individuals” to “a community effort”.&lt;/p&gt;

&lt;h2 id=&quot;growing-a-community&quot;&gt;Growing a Community&lt;/h2&gt;

&lt;blockquote&gt;
  &lt;p&gt;Why do individuals volounteer their time for organizations? What motivates people to contribute?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;We volounteer when we believe our values align, when we are uniquely qualified to help, and when our efforts will have impact. To give would-be-contributors a chance to evaluate statements like these, we first need to clearly demonstrate our own values and efforts.&lt;/p&gt;

&lt;p&gt;How do we do this? By:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Providing consistent, cohesive, and helpful documentation&lt;/li&gt;
  &lt;li&gt;Being responsive, helpful, and approachable (re: GitHub issues and pull requests)&lt;/li&gt;
  &lt;li&gt;Creating opportunities to share knowledge, take ownership, and have impact&lt;/li&gt;
  &lt;li&gt;Displaying an identity and culture that community members resonate with&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Adopting a logo, branding, and consistent style helps move a few of these bullet points forward.&lt;/p&gt;

&lt;h2 id=&quot;sourcing-logo-designs&quot;&gt;Sourcing Logo Designs&lt;/h2&gt;

&lt;p&gt;I originally reached out to the Slack Group to see if any organizations or individuals could provide design resources. &lt;em&gt;insert cricket sounds here&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Failing that, I ventured over to &lt;a href=&quot;https://fiverr.com&quot;&gt;Fiverr.com&lt;/a&gt; to see what &amp;lt; $100 of my own personal funds could make happen. Surprisingly, a lot. I provided some rough guidelines and example look-and-feel logos to the &lt;em&gt;very&lt;/em&gt; talented &lt;a href=&quot;https://www.fiverr.com/artfeel_&quot;&gt;Artfeel_&lt;/a&gt;. She came back with the following concepts:&lt;/p&gt;

&lt;figure class=&quot;w-1 pad-me&quot;&gt;
		&lt;img src=&quot;/assets/img/blog/2019/02/25/style-variations.png&quot; alt=&quot;Variations of new logo concepts&quot; /&gt;
    &lt;caption&gt;$72 worth of logo concepts.&lt;/caption&gt;
&lt;/figure&gt;

&lt;p&gt;Erik Ziegler, James A. Petts, and myself discussed the above options. We ultimately settled on “The Blob” (as we endearingly named it). After playing a bit of word association, we believe it reinforces:&lt;/p&gt;

&lt;p&gt;fluid, liquid, malleable, volume, adaptable, “part of”&lt;/p&gt;

&lt;p&gt;With the ultimate goal that it reminds our libraries’ consumers that cornerstone.js is a “core building block” for larger applications and medical image viewers – even as our landscape (and the library’s purpose) shifts and changes.&lt;/p&gt;

&lt;p&gt;We then played with a few different color variations:&lt;/p&gt;

&lt;figure class=&quot;w-1 pad-me&quot;&gt;
		&lt;img src=&quot;/assets/img/blog/2019/02/25/color-variations.png&quot; alt=&quot;Variations of logo color&quot; /&gt;
    &lt;caption&gt;Color variations of &quot;The Blob&quot; when shifting the hue of the three main colors that comprise its gradiants.&lt;/caption&gt;
&lt;/figure&gt;

&lt;p&gt;We decided to stick with the original green for now, but believe the gradiant and alternative colors could allow for some interesting use cases and animations at a later time.&lt;/p&gt;

&lt;p&gt;Our last stick point revolved around usage of “.js” in the logo’s design.&lt;/p&gt;

&lt;figure class=&quot;w-1 pad-me&quot;&gt;
		&lt;img src=&quot;/assets/img/blog/2019/02/25/cornerstonejs-new-logo.png&quot; alt=&quot;Grid of our new logo with different background colors&quot; /&gt;
    &lt;caption&gt;Finalized Cornerstone.js &quot;The Blob&quot; Logos&lt;/caption&gt;
&lt;/figure&gt;

&lt;p&gt;Reinforcing “cornerstone.js” over “cornerstone” is of prime importance. Cornerstone, on its own, is less descriptive and can be difficult to locate us by. Our rule of thumb is:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;When included alongside the text &lt;code class=&quot;highlighter-rouge&quot;&gt;cornerstone.js&lt;/code&gt;, the &lt;code class=&quot;highlighter-rouge&quot;&gt;.js&lt;/code&gt; may be absent from “The Blob”&lt;/li&gt;
  &lt;li&gt;When displayed solely as “The Blob”, the &lt;code class=&quot;highlighter-rouge&quot;&gt;.js&lt;/code&gt; should be present to reinforce “cornerstone.js”&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;assets-and-usage-guidelines&quot;&gt;Assets and Usage Guidelines&lt;/h3&gt;

&lt;p&gt;&lt;a href=&quot;https://github.com/cornerstonejs/style-guide&quot;&gt;You can find our current style guide on GitHub&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It includes assets you can use in your own projects, and serves as a reference for our own repositories.&lt;/p&gt;

&lt;h4 id=&quot;disclaimer&quot;&gt;Disclaimer&lt;/h4&gt;

&lt;p&gt;This post is purposely brief. Cornerstone’s history is long, rich, and filled with countless contributors that have helped it grow to where it is today. If you feel something is innacurate or requires updating, please don’t hesitate to reach out to me directly or in the comments below.&lt;/p&gt;</content><author><name>Danny Brown</name><email>danny.ri.brown@gmail.com</email></author><category term="cornerstone.js" /><category term="design" /><category term="branding" /><category term="community" /><summary type="html">For those not aware, I became a core team member of Cornerstone.js in late 2017. Since then, I’ve actively worked to improve the cornerstone.js libaries and grow its community. Today, as a part of those efforts, we have developed a style guide and adopted a new logo. Here’s a piece on how we found our way.</summary></entry><entry><title type="html">Graduating from Boostrap: With help from Atomic Design</title><link href="https://dannyrb.com/blog/2017-10-06-graduating-from-bootstrap-with-help-from-atomic-design/" rel="alternate" type="text/html" title="Graduating from Boostrap: With help from Atomic Design" /><published>2017-10-06T00:00:00+00:00</published><updated>2017-10-06T00:00:00+00:00</updated><id>https://dannyrb.com/blog/graduating-from-bootstrap-with-help-from-atomic-design</id><content type="html" xml:base="https://dannyrb.com/blog/2017-10-06-graduating-from-bootstrap-with-help-from-atomic-design/">&lt;p&gt;When replying to a conference’s “Call for Speakers” or “Call for Proposals” you often submit an abstract. The abstract serves as a pitch for a topic you would be interested in speaking on. Often times, the talk does not have slides or even an outline at this point. If one or more conferences likes the abstract and asks the submitter to present, a talk is born.&lt;/p&gt;

&lt;!--more--&gt;

&lt;h2 id=&quot;abstract&quot;&gt;Abstract&lt;/h2&gt;

&lt;p&gt;Here is a copy of the abstract that ultimately led to this slide deck and presentation:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Bootstrap defines itself as “… the most popular HTML, CSS, and JS framework for developing responsive, mobile first projects on the web.” and it’s not wrong. At 105,000 stars, and over 48,000 forks on GitHub, it comes in as the second most popular repository of all time. Bootstrap is an amazing tool, but it’s not without it’s problems. Have you ever found yourself overriding a default Bootstrap style? Including CSS or JS for components you don’t use? Or maybe you’re just tired of your website looking like everyone else’s? We put up with this technical debt because of the wins Bootstrap provides, but what if we could keep the benefits without all of the headache? Enter Atomic Design.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;blockquote&gt;
  &lt;p&gt;In this discussion, we will start by exploring the problems Atomic design solves, how it promotes consistency/cohesion, easily traverses from abstract to concrete, and provides methodology for crafting an effective design system. Next we will get our hands dirty by digging into a concrete implementation of an Atomic Design based toolkit. Finally, we will go over resources for further education, how to begin the process of integrating Atomic Design into your process, and next steps. By the end of this talk you will be comfortable with Atomic Design basics and have the knowledge and resources necessary to create your own atomically driven comprehensive component library.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2 id=&quot;slide-deck&quot;&gt;Slide Deck&lt;/h2&gt;

&lt;p&gt;&lt;a href=&quot;http://slides.com/dannyrb/graduating-from-bootstrap-pattern-libraries/fullscreen&quot;&gt;Click Here to view on slides.com&lt;/a&gt;&lt;/p&gt;

&lt;iframe style=&quot;max-width: 100%&quot; src=&quot;//slides.com/dannyrb/graduating-from-bootstrap-pattern-libraries/embed&quot; width=&quot;576&quot; height=&quot;420&quot; scrolling=&quot;no&quot; frameborder=&quot;0&quot; webkitallowfullscreen=&quot;&quot; mozallowfullscreen=&quot;&quot; allowfullscreen=&quot;&quot;&gt;&lt;/iframe&gt;

&lt;p&gt;Fullscreen is not available/does not function correctly within this layout. You can view the speaker notes and the slides in their full resolution on slides.com.&lt;/p&gt;

&lt;p&gt;This talk was presented at &lt;a href=&quot;http://techbash.com&quot;&gt;Techbash 2017&lt;/a&gt;. You can find information about the other wonderful talks presented there in &lt;a href=&quot;https://github.com/TechBash/TechBash2017&quot;&gt;this GitHub Repo&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;If you have any questions, please don’t hesitate to reach out below!&lt;/p&gt;</content><author><name>Danny Brown</name><email>danny.ri.brown@gmail.com</email></author><category term="design systems" /><category term="front-end" /><summary type="html">When replying to a conference’s “Call for Speakers” or “Call for Proposals” you often submit an abstract. The abstract serves as a pitch for a topic you would be interested in speaking on. Often times, the talk does not have slides or even an outline at this point. If one or more conferences likes the abstract and asks the submitter to present, a talk is born.</summary></entry><entry><title type="html">How To Use Google Analytics’ API To Share Your Traffic</title><link href="https://dannyrb.com/blog/2015-11-10-how-to-use-google-analytics-api-to-share-your-traffic/" rel="alternate" type="text/html" title="How To Use Google Analytics' API To Share Your Traffic" /><published>2015-11-10T00:00:00+00:00</published><updated>2015-11-10T00:00:00+00:00</updated><id>https://dannyrb.com/blog/how-to-use-google-analytics-api-to-share-your-traffic</id><content type="html" xml:base="https://dannyrb.com/blog/2015-11-10-how-to-use-google-analytics-api-to-share-your-traffic/">&lt;p&gt;This is a “proof of concept” post on open sourcing your website’s traffic data. A number of enhancements, both visual and performance wise, can be made. This post walks you through getting the data into your hands, so you can do with it what you will (:&lt;/p&gt;

&lt;!--more--&gt;

&lt;p&gt;&lt;strong&gt;Finished Product:&lt;/strong&gt; &lt;a href=&quot;http://dannyrb.com/traffic/&quot;&gt;Advanced&lt;/a&gt; == OR == &lt;a href=&quot;http://dannyrb.com/traffic/examples/embedded-api-render.php&quot;&gt;Basic&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Project on GitHub:&lt;/strong&gt; &lt;a href=&quot;https://github.com/dannyrb/google-analytics-traffic&quot;&gt;Click Here&lt;/a&gt;&lt;/p&gt;

&lt;h2 id=&quot;sharing-your-traffic&quot;&gt;Sharing Your Traffic&lt;/h2&gt;

&lt;p&gt;One of the most difficult components of working with Google’s APIs is authentication. Thankfully, Google has a number of &lt;a href=&quot;https://developers.google.com/discovery/libraries?hl=en&quot;&gt;client libraries&lt;/a&gt; that make this easier.&lt;/p&gt;

&lt;p&gt;For this guide, we’ll be using:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Google’s &lt;a href=&quot;https://developers.google.com/api-client-library/php/&quot;&gt;PHP API Client Library&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Google’s &lt;a href=&quot;https://ga-dev-tools.appspot.com/embed-api/server-side-authorization/&quot;&gt;Embeded API&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;We’re doing this for a couple of reasons. First, I eventually want to package this code into a reusable HTML WebComponent. Second, the Javascript API cannot generate it’s own Auth Token; it needs to be passed one from a server side call.&lt;/p&gt;

&lt;p&gt;It’s worth noting that we could swap out the PHP portion of the code with any of Google’s other &lt;a href=&quot;https://developers.google.com/discovery/libraries?hl=en&quot;&gt;API Client Libraries&lt;/a&gt;.&lt;/p&gt;

&lt;h3 id=&quot;installing-php-api-client-library&quot;&gt;Installing PHP API Client Library&lt;/h3&gt;

&lt;p&gt;You need a local PHP server for this to work well. If you don’t already, look into setting one up using either:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.apachefriends.org/index.html&quot;&gt;XAMPP&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://php.iis.net/&quot;&gt;Or add PHP to IIS&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;After installing a local server, make sure you have composer installed:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://getcomposer.org/doc/00-intro.md&quot;&gt;Get Composer!&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Next. open up a new command prompt window. Navigate to your product directory and use this command:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;composer require google/apiclient:^2.0.0@RC&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you receive an error, you may want to try:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;composer require google/apiclient:^2@RC&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Or check out the GitHub Repository for &lt;a href=&quot;https://github.com/google/google-api-php-client&quot;&gt;Google’s PHP API Client&lt;/a&gt; as the install instructions may have changed.&lt;/p&gt;

&lt;h3 id=&quot;google-developers-console&quot;&gt;Google Developers Console&lt;/h3&gt;

&lt;p&gt;This is where you manage permissions and account associations for all of Google’s APIs. We need to navigate to the &lt;a href=&quot;https://console.developers.google.com/project&quot;&gt;Developer Console&lt;/a&gt; and &lt;strong&gt;create a reference to the project that will be pulling our analytics data.&lt;/strong&gt;&lt;/p&gt;

&lt;figure class=&quot;w-1 pad-me&quot;&gt;
		&lt;img src=&quot;/assets/img/blog/2015/11/10/create-project-google-dev-console.png&quot; alt=&quot;example of creating a new project in google developer console&quot; /&gt;
&lt;/figure&gt;

&lt;p&gt;Next, we need to &lt;strong&gt;turn on API Access to Google Analytics&lt;/strong&gt; for this project. From your new project’s dashboard, navigate to “API”, then “Analytics”. You should see this screen. Click “Enable” to turn on support for the Analytic’s API.&lt;/p&gt;

&lt;figure class=&quot;w-1 pad-me&quot;&gt;
		&lt;img src=&quot;/assets/img/blog/2015/11/10/enable-api-google-dev-console.png&quot; alt=&quot;example of adding API permissions in google developer console&quot; /&gt;
&lt;/figure&gt;

&lt;h3 id=&quot;service-accounts&quot;&gt;Service Accounts&lt;/h3&gt;

&lt;p&gt;Okay, now Google requires an authenticated account to access account specific data. We don’t want our users to have to authenticate (they couldn’t see our data anyway). To get around this, Google uses &lt;a href=&quot;https://developers.google.com/identity/protocols/OAuth2ServiceAccount&quot;&gt;Service Accounts&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Think of our Service Account as just another user account. We need to:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Create it ;)  (It has it’s own e-mail address)&lt;/li&gt;
  &lt;li&gt;Grant it account permissions in Google Analytics&lt;/li&gt;
  &lt;li&gt;Use it’s credentials to authenticate before requesting data&lt;/li&gt;
&lt;/ul&gt;

&lt;h4 id=&quot;create-a-service-account&quot;&gt;Create A Service Account&lt;/h4&gt;

&lt;p&gt;To create a service account, we head back to the Google Developer Console, and access the project we created in our previous steps. You &lt;strong&gt;select “Credentials”, “Add Credentials”, and then “Service Account”.&lt;/strong&gt; You should see your newly created service account as pictured below! Make sure to &lt;strong&gt;save the e-mail address of your new account&lt;/strong&gt; in a text file. We’ll be using it in the next steps.&lt;/p&gt;

&lt;figure class=&quot;w-1 pad-me&quot;&gt;
		&lt;img src=&quot;/assets/img/blog/2015/11/10/add-service-account-google-dev-console.png&quot; alt=&quot;example of adding a service account in google developer console&quot; /&gt;
&lt;/figure&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; In the last step, you should have been forced to download a JSON Key file. If you don’t have one, or you’ve lost yours, you can generate a new file by viewing the details of your service account and clicking “Generate New JSON Key”&lt;/p&gt;

&lt;h4 id=&quot;give-our-service-account-permissions&quot;&gt;Give Our Service Account Permissions&lt;/h4&gt;

&lt;p&gt;Next, we need to make sure our Service Account has permission to read the data we want to query. We can give it permission by logging in to our Google Analytics account, navigating to “Admin”, under “Account” selecting “User Management”, and finally by &lt;strong&gt;adding “Read &amp;amp; Analyze” permissions for our Service Account using its e-mail address.&lt;/strong&gt;&lt;/p&gt;

&lt;figure class=&quot;w-1 pad-me&quot;&gt;
		&lt;img src=&quot;/assets/img/blog/2015/11/10/add-permisions.png&quot; alt=&quot;example of adding a service account in google developer console&quot; /&gt;
&lt;/figure&gt;

&lt;h3 id=&quot;querying-data&quot;&gt;Querying Data&lt;/h3&gt;

&lt;p&gt;And finally… Lets write some code. Here is the general run-down of what we need to do:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Use &lt;em&gt;server-side&lt;/em&gt; library to authenticate our service account&lt;/li&gt;
  &lt;li&gt;Authentication process provides us an &lt;em&gt;access token&lt;/em&gt;&lt;/li&gt;
  &lt;li&gt;Pass &lt;em&gt;access token&lt;/em&gt; to &lt;em&gt;client-side&lt;/em&gt; api&lt;/li&gt;
  &lt;li&gt;Query for data using embedded &lt;em&gt;client-side&lt;/em&gt; api&lt;/li&gt;
  &lt;li&gt;Render charts using built in functions&lt;/li&gt;
&lt;/ul&gt;

&lt;h4 id=&quot;server-side-code&quot;&gt;Server-Side Code&lt;/h4&gt;

&lt;div class=&quot;language-php highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;cp&quot;&gt;&amp;lt;?php&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;// MUST be using composer&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;require_once&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'/path/to/vendor/autoload.php'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;session_start&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;	 	

&lt;span class=&quot;nv&quot;&gt;$client&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Google_Client&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;	 	
&lt;span class=&quot;c1&quot;&gt;// Name of proj in GoogleDeveloperConsole&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;$client&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;setApplicationName&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Example Project&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;// Generated in GoogleDeveloperConsole --&amp;gt; Credentials --&amp;gt; Service Accounts&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;$client&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;setAuthConfig&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'/some/secure/path/example-project-c0a14bc34a03.json'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;$client&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;addScope&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Google_Service_Analytics&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;ANALYTICS_READONLY&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;// Grab token if it's set&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;isset&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$_SESSION&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'service_token'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]))&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
 	&lt;span class=&quot;nv&quot;&gt;$client&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;setAccessToken&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$_SESSION&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'service_token'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;// Refresh if expired&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$client&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;isAccessTokenExpired&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;())&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
	&lt;span class=&quot;nv&quot;&gt;$client&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;refreshTokenWithAssertion&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;// Pin to Session&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;$_SESSION&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'service_token'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$client&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getAccessToken&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;

&lt;span class=&quot;nv&quot;&gt;$myToken&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$client&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getAccessToken&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
&lt;span class=&quot;cp&quot;&gt;?&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Note:&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;The &lt;code class=&quot;highlighter-rouge&quot;&gt;require_once&lt;/code&gt; is referencing a file generated by Composer.&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;setApplicationName()&lt;/code&gt; is being passed the name of our project&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;setAuthConfig()&lt;/code&gt; is passed the location of our JSON Key file
    &lt;ul&gt;
      &lt;li&gt;Please put this in a secure place&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h4 id=&quot;client-side-code&quot;&gt;Client-Side Code&lt;/h4&gt;

&lt;div class=&quot;language-html highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;&amp;lt;!-- Load Google's Embed API Library --&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;script&amp;gt;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;w&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;d&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;g&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;js&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;fs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;){&lt;/span&gt;
&lt;span class=&quot;nx&quot;&gt;g&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;w&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;gapi&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;||&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;w&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;gapi&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{});&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;g&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;analytics&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;q&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:[],&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;ready&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;){&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;q&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;push&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);}};&lt;/span&gt;
&lt;span class=&quot;nx&quot;&gt;js&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;d&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;createElement&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;fs&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;d&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;getElementsByTagName&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;];&lt;/span&gt;
&lt;span class=&quot;nx&quot;&gt;js&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'https://apis.google.com/js/platform.js'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;nx&quot;&gt;fs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;parentNode&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;insertBefore&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;js&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;fs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;js&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;onload&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(){&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;g&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;load&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'analytics'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);};&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;document&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'script'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;));&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;

&lt;span class=&quot;nt&quot;&gt;&amp;lt;div&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;id=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;chart-1-container&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&amp;lt;/div&amp;gt;&lt;/span&gt;

&lt;span class=&quot;nt&quot;&gt;&amp;lt;script&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nx&quot;&gt;gapi&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;analytics&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;ready&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;

  &lt;span class=&quot;cm&quot;&gt;/**
   * Authorize the user with an access token obtained server side.
   */&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;gapi&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;analytics&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;auth&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;authorize&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;({&lt;/span&gt;
    &lt;span class=&quot;s1&quot;&gt;'serverAuth'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;s1&quot;&gt;'access_token'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'&amp;lt;?php print_r($myToken[&quot;access_token&quot;]); ?&amp;gt;'&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;

  &lt;span class=&quot;cm&quot;&gt;/**
   * Creates a new DataChart instance showing sessions over the past 30 days.
   * It will be rendered inside an element with the id &quot;chart-1-container&quot;.
   */&lt;/span&gt;
  &lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;dataChart1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;gapi&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;analytics&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;googleCharts&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;DataChart&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;({&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;query&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;s1&quot;&gt;'ids'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'ga:110849216'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; 			&lt;span class=&quot;c1&quot;&gt;// THIS NEEDS TO BE A VIEW&lt;/span&gt;
      &lt;span class=&quot;s1&quot;&gt;'start-date'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'30daysAgo'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;		&lt;span class=&quot;c1&quot;&gt;// THAT YOUR SERVICE ACCOUNT HAS&lt;/span&gt;
      &lt;span class=&quot;s1&quot;&gt;'end-date'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'yesterday'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;			&lt;span class=&quot;c1&quot;&gt;// ACCESS TO&lt;/span&gt;
      &lt;span class=&quot;s1&quot;&gt;'metrics'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'ga:sessions,ga:users'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
      &lt;span class=&quot;s1&quot;&gt;'dimensions'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'ga:date'&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;chart&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;s1&quot;&gt;'container'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'chart-1-container'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
      &lt;span class=&quot;s1&quot;&gt;'type'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'LINE'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
      &lt;span class=&quot;s1&quot;&gt;'options'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;s1&quot;&gt;'width'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'100%'&lt;/span&gt;
      &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;dataChart1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;execute&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Note:&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Our &lt;code class=&quot;highlighter-rouge&quot;&gt;accessToken&lt;/code&gt; is being passed in by the &lt;em&gt;server-side&lt;/em&gt; language&lt;/li&gt;
  &lt;li&gt;Our ViewID &lt;code class=&quot;highlighter-rouge&quot;&gt;'ids': 'ga:110849216'&lt;/code&gt; is specific to our &lt;a href=&quot;/assets/img/blog/2015/11/10/find-view-id.png&quot;&gt;Analytics View&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;our-result&quot;&gt;Our Result&lt;/h3&gt;

&lt;figure class=&quot;w-1 pad-me&quot;&gt;
	&lt;a href=&quot;http://dannyrb.com/traffic/&quot;&gt;
		&lt;img src=&quot;/assets/img/blog/2015/11/10/example-graph.png&quot; alt=&quot;line graph of our resulting data&quot; /&gt;
		&lt;figcaption&gt;Click here to see the live result&lt;/figcaption&gt;
	&lt;/a&gt;
&lt;/figure&gt;

&lt;p&gt;Not beautiful, or even super functional, but it’s a good start!&lt;/p&gt;

&lt;h2 id=&quot;what-next&quot;&gt;What Next?&lt;/h2&gt;

&lt;p&gt;This is a proof of concept, so there are plenty of enhancements that can be made. On the visual UI/UX side we have:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Set up charts to &lt;a href=&quot;https://ga-dev-tools.appspot.com/embed-api/multiple-views/&quot;&gt;work for multiple analytic “views”&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Add support for &lt;a href=&quot;https://developers.google.com/analytics/devguides/reporting/realtime/v3/&quot;&gt;real-time reporting&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Use Chart.js or &lt;a href=&quot;https://ga-dev-tools.appspot.com/embed-api/third-party-visualizations/&quot;&gt;similar libraries to enhance charts&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But there are also performance issues that should be considered. You may want to look into storing common requests into a database, and then using data from your local database to display charts. This has the benefit of using less of your &lt;em&gt;query quota&lt;/em&gt; (set by Google), and the page should load much faster coming from a local data source.&lt;/p&gt;

&lt;h4 id=&quot;stuck&quot;&gt;Stuck?&lt;/h4&gt;

&lt;p&gt;If you’re stuck on a step, it could because my guide is now outdated. Try Googling the problem, but don’t be afraid to ask for help in the comments below. I really, really appreciate any advice, feedback, and questions.&lt;/p&gt;

&lt;h2 id=&quot;resources&quot;&gt;Resources&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Libraries and Google Documentation&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://developers.google.com/analytics/devguides/config/mgmt/v3/mgmtReference/management/profiles/list?hl=en#try-it&quot;&gt;Determine “Views” you can access&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/google/google-api-php-client&quot;&gt;Google’s PHP API Client&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://ga-dev-tools.appspot.com/embed-api/&quot;&gt;Embeded API Tutorials&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Crafting different &lt;a href=&quot;https://ga-dev-tools.appspot.com/query-explorer/&quot;&gt;queries to pull back data&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;My repositories:&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Main example &lt;a href=&quot;https://github.com/dannyrb/google-analytics-traffic/blob/master/index.php&quot;&gt;on GitHub&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;PHP Only example &lt;a href=&quot;https://github.com/dannyrb/google-analytics-traffic/blob/master/examples/php-only-data-query.php&quot;&gt;on GitHub&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Other Blogs/Guides&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Most of these use deprecated functions, but they provided a lot of clarity to the process for me. I hope they can help, and if you have specific questions, please feel free to reach out.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.daimto.com/google-calendar-api-with-php-service-account/&quot;&gt;Google Calendar API with PHP – Service Account&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.daimto.com/google-oauth2-php/&quot;&gt;Google Analytics OAuth2 – PHP&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.daimto.com/googleanalytics-authentication-csharp/&quot;&gt;Google Analytics API Authentication with C#&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</content><author><name>Danny Brown</name><email>danny.ri.brown@gmail.com</email></author><category term="google analytics api" /><category term="open source" /><category term="php" /><category term="javascript" /><summary type="html">This is a “proof of concept” post on open sourcing your website’s traffic data. A number of enhancements, both visual and performance wise, can be made. This post walks you through getting the data into your hands, so you can do with it what you will (:</summary></entry><entry><title type="html">SEO Meta Tags and Microdata for Blogs</title><link href="https://dannyrb.com/blog/2015-11-08-seo-meta-tags-and-microdata-for-blogs/" rel="alternate" type="text/html" title="SEO Meta Tags and Microdata for Blogs" /><published>2015-11-08T00:00:00+00:00</published><updated>2015-11-08T00:00:00+00:00</updated><id>https://dannyrb.com/blog/seo-meta-tags-and-microdata-for-blogs</id><content type="html" xml:base="https://dannyrb.com/blog/2015-11-08-seo-meta-tags-and-microdata-for-blogs/">&lt;p&gt;A quick, no explanation reference on how to optimize blog posts and blogs for search engines.&lt;/p&gt;

&lt;!--more--&gt;

&lt;h2 id=&quot;meta-tags&quot;&gt;Meta Tags&lt;/h2&gt;

&lt;p&gt;Meta tags go in the &lt;code class=&quot;highlighter-rouge&quot;&gt;&amp;lt;head&amp;gt;&lt;/code&gt; of an HTML document. They add additional information/context to the current web page or website.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;OpenGraph: Facebook tags&lt;/li&gt;
  &lt;li&gt;Schema.org: Bing, Yahoo, Google, etc.&lt;/li&gt;
  &lt;li&gt;Twitter: … Twitter&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-html highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;&amp;lt;!-- Update your html tag to include the itemscope and itemtype attributes. --&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;html&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;itemscope&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;itemtype=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;http://schema.org/Article&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;&amp;lt;!-- Place this data between the &amp;lt;head&amp;gt; tags of your website --&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;title&amp;gt;&lt;/span&gt;Page Title. Maximum length 60-70 characters&lt;span class=&quot;nt&quot;&gt;&amp;lt;/title&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;meta&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;description&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;content=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Page description. No longer than 155 characters.&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;&amp;lt;!-- Schema.org markup for Google+ --&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;meta&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;itemprop=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;name&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;content=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;The Name or Title Here&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;meta&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;itemprop=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;description&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;content=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;This is the page description&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;meta&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;itemprop=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;image&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;content=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;http://www.example.com/image.jpg&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;&amp;lt;!-- Twitter Card data --&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;meta&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;twitter:card&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;content=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;summary_large_image&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;meta&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;twitter:site&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;content=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;@publisher_handle&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;meta&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;twitter:title&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;content=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Page Title&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;meta&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;twitter:description&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;content=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Page description less than 200 characters&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;meta&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;twitter:creator&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;content=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;@author_handle&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;&amp;lt;!-- Twitter summary card with large image must be at least 280x150px --&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;meta&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;twitter:image:src&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;content=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;http://www.example.com/image.html&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;&amp;lt;!-- Open Graph data --&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;meta&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;property=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;og:title&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;content=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Title Here&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;meta&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;property=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;og:type&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;content=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;article&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;meta&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;property=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;og:url&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;content=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;http://www.example.com/&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;&amp;lt;!-- 1200 x 630 For optimal sharing --&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;meta&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;property=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;og:image&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;content=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;http://example.com/image.jpg&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;meta&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;property=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;og:description&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;content=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Description Here&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;meta&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;property=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;og:site_name&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;content=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Site Name, i.e. Moz&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;meta&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;property=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;article:published_time&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;content=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;2013-09-17T05:59:00+01:00&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;meta&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;property=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;article:modified_time&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;content=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;2013-09-16T19:08:47+01:00&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;meta&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;property=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;article:section&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;content=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Article Section&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;meta&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;property=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;article:tag&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;content=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Article Tag&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;meta&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;property=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;fb:admins&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;content=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Facebook numberic ID&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;HERE: &lt;a href=&quot;https://gist.github.com/dannyrb/8a2d374558ba2cef2d3d&quot;&gt;As a GitHub Gist&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you want to see if you’ve set these correctly, you can check to see how each of the appropriate vendors reads your webpage.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;OpenGraph Validator: &lt;a href=&quot;https://developers.facebook.com/tools/debug/&quot;&gt;HERE&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Twitter Card Validator: &lt;a href=&quot;https://cards-dev.twitter.com/validator&quot;&gt;HERE&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Schema.org Validator: &lt;a href=&quot;https://developers.google.com/structured-data/testing-tool/&quot;&gt;HERE&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;more-reading&quot;&gt;More Reading&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;OpenGraph Guide: &lt;a href=&quot;http://ogp.me/&quot;&gt;HERE&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Twitter Guide: &lt;a href=&quot;https://dev.twitter.com/cards/overview&quot;&gt;Here&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Schema.org Guide: &lt;a href=&quot;http://www.internetmarketingninjas.com/blog/search-engine-optimization/schema-org-guide-beginners-cheatsheet/&quot;&gt;Here&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;semantic-markup&quot;&gt;Semantic Markup&lt;/h2&gt;

&lt;p&gt;Does your websites HTML markup contain a large number of &lt;code class=&quot;highlighter-rouge&quot;&gt;&amp;lt;div&amp;gt;&lt;/code&gt; elements?!?! Use HTML tags that are more semantic/descriptive of the content they contain! &lt;code class=&quot;highlighter-rouge&quot;&gt;&amp;lt;div&amp;gt;s&lt;/code&gt; can be replaced with…&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;&amp;lt;article&amp;gt;&lt;/code&gt;
&lt;code class=&quot;highlighter-rouge&quot;&gt;&amp;lt;aside&amp;gt;&lt;/code&gt;
&lt;code class=&quot;highlighter-rouge&quot;&gt;&amp;lt;details&amp;gt;&lt;/code&gt;
&lt;code class=&quot;highlighter-rouge&quot;&gt;&amp;lt;figure&amp;gt;&lt;/code&gt;
&lt;code class=&quot;highlighter-rouge&quot;&gt;&amp;lt;figcaption&amp;gt;&lt;/code&gt;
&lt;code class=&quot;highlighter-rouge&quot;&gt;&amp;lt;footer&amp;gt;&lt;/code&gt;
&lt;code class=&quot;highlighter-rouge&quot;&gt;&amp;lt;header&amp;gt;&lt;/code&gt;
&lt;code class=&quot;highlighter-rouge&quot;&gt;&amp;lt;main&amp;gt;&lt;/code&gt;
&lt;code class=&quot;highlighter-rouge&quot;&gt;&amp;lt;nav&amp;gt;&lt;/code&gt;
&lt;code class=&quot;highlighter-rouge&quot;&gt;&amp;lt;section&amp;gt;&lt;/code&gt;
&lt;code class=&quot;highlighter-rouge&quot;&gt;&amp;lt;summary&amp;gt;&lt;/code&gt;
&lt;code class=&quot;highlighter-rouge&quot;&gt;&amp;lt;time&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Mostly self explanatory, but there are &lt;em&gt;a couple&lt;/em&gt; rules to how these should be used. For some direction, try reading my &lt;a href=&quot;http://127.0.0.1:4000/posts/the-programmers-guide-to-better-seo-semantic-markup-and-html5/&quot;&gt;more in-depth post on HTML5’s sectioning elements&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;other-stuff&quot;&gt;Other Stuff&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;Make it easy to share content&lt;/li&gt;
  &lt;li&gt;HAVE AMAZING CONTENT (and original)&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;alt&lt;/code&gt; tags for images&lt;/li&gt;
  &lt;li&gt;Sign up for Google’s &lt;a href=&quot;https://www.google.com/webmasters/tools/home&quot;&gt;webmaster tools&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Make your website mobile friendly&lt;/li&gt;
  &lt;li&gt;Increase page load times&lt;/li&gt;
  &lt;li&gt;URLs should contain key words to content on page&lt;/li&gt;
  &lt;li&gt;Add SSL to your website&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;But most importantly.. Provide solid, original content, and a great user experience.&lt;/strong&gt;&lt;/p&gt;</content><author><name>Danny Brown</name><email>danny.ri.brown@gmail.com</email></author><category term="seo" /><category term="html5" /><category term="blogs" /><category term="microdata" /><category term="schema.org" /><category term="semantic" /><summary type="html">A quick, no explanation reference on how to optimize blog posts and blogs for search engines.</summary></entry><entry><title type="html">The Template Tag: A Refresher</title><link href="https://dannyrb.com/blog/2015-11-05-the-template-tag-a-refresher/" rel="alternate" type="text/html" title="The Template Tag: A Refresher" /><published>2015-11-05T00:00:00+00:00</published><updated>2015-11-05T00:00:00+00:00</updated><id>https://dannyrb.com/blog/the-template-tag-a-refresher</id><content type="html" xml:base="https://dannyrb.com/blog/2015-11-05-the-template-tag-a-refresher/">&lt;p&gt;The &lt;code class=&quot;highlighter-rouge&quot;&gt;&amp;lt;template&amp;gt;&lt;/code&gt; specification was &lt;a href=&quot;https://fronteers.nl/congres/2011/sessions/web-components-and-model-driven-views-alex-russell&quot;&gt;introduced in 2011&lt;/a&gt;, along with the other three specs that make up WebComponents. Since then, &lt;code class=&quot;highlighter-rouge&quot;&gt;&amp;lt;template&amp;gt;&lt;/code&gt; has become a part of the &lt;a href=&quot;http://www.w3.org/TR/html5/scripting-1.html#the-template-element&quot;&gt;W3C Living Document&lt;/a&gt;, and has full support in Chrome, Firefox, Opera, Safari, and Android. To boot, Edge has just announced &lt;a href=&quot;https://dev.modern.ie/platform/status/templateelement/&quot;&gt;upcoming support&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;In light of that announcement, let’s refresh (:&lt;/p&gt;

&lt;!--more--&gt;

&lt;h2 id=&quot;native-templates&quot;&gt;Native Templates&lt;/h2&gt;

&lt;p&gt;Before the &lt;code class=&quot;highlighter-rouge&quot;&gt;&amp;lt;template&amp;gt;&lt;/code&gt; tag was introduced we still had templates, but to get them to work, we had to abuse existing functionality. The two most common techniques were:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Hide the DOM off screen
```html&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;hidden-template&quot; id=&quot;template-22&quot;&gt;
    &lt;!-- My template's contents --&gt;
&lt;/div&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;

&amp;lt;ol start=&quot;2&quot;&amp;gt;
	&amp;lt;li&amp;gt;Abusing the &amp;lt;code&amp;gt;&amp;amp;lt;script&amp;amp;gt;&amp;lt;/code&amp;gt; tag&amp;lt;/li&amp;gt;
&amp;lt;/ol&amp;gt;
```html
&amp;lt;script id=&quot;simple-template&quot; type=&quot;text/x-handlebars-template&quot;&amp;gt;
  // My template's contents
&amp;lt;/script&amp;gt; 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Both of these techniques are not ideal. The first is clunky and can be accidentally modified by DOM manipulation. The latter exposes us to potential cross-site scripting attacks. The &lt;code class=&quot;highlighter-rouge&quot;&gt;&amp;lt;template&amp;gt;&lt;/code&gt; element seeks to solve these issues, and also provides additional benefits.&lt;/p&gt;

&lt;h3 id=&quot;the-anatomy-of-a-template&quot;&gt;The Anatomy of a Template&lt;/h3&gt;

&lt;p&gt;The anatomy of a template is simple. It is any set of markup, styles, and javascript that is wrapped in &lt;code class=&quot;highlighter-rouge&quot;&gt;&amp;lt;template&amp;gt;&lt;/code&gt; tags. A template can even include another template! Here is a basic example:&lt;/p&gt;

&lt;div class=&quot;language-html highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;template&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;id=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;simple&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;style&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;nt&quot;&gt;span&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;nl&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;purple&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;/style&amp;gt;&lt;/span&gt;

    &lt;span class=&quot;nt&quot;&gt;&amp;lt;img&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;src=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;http://placehold.it/50x50&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;span&amp;gt;&lt;/span&gt;Hello World!&lt;span class=&quot;nt&quot;&gt;&amp;lt;/span&amp;gt;&lt;/span&gt;

    &lt;span class=&quot;nt&quot;&gt;&amp;lt;script&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;boom&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(){&lt;/span&gt;
            &lt;span class=&quot;nx&quot;&gt;alert&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;BOOM!&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
        &lt;span class=&quot;nx&quot;&gt;boom&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/template&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;the-properties-of-a-template&quot;&gt;The Properties of a Template&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Flexible placement&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This code can live anywhere inside the &lt;code class=&quot;highlighter-rouge&quot;&gt;&amp;lt;head&amp;gt;&lt;/code&gt; or &lt;code class=&quot;highlighter-rouge&quot;&gt;&amp;lt;body&amp;gt;&lt;/code&gt;. It’s also important to note that you can place it as a child for a &lt;code class=&quot;highlighter-rouge&quot;&gt;&amp;lt;select&amp;gt;&lt;/code&gt; or &lt;code class=&quot;highlighter-rouge&quot;&gt;&amp;lt;table&amp;gt;&lt;/code&gt; element.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Inert&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This means that the Javascript and CSS play no role in modifying the page. The code is not active until the template has been cloned and added to the page.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Hidden from CSS and Selectors&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Your template’s content cannot be selected or modified with CSS or query selectors. This is to protect it from accidental changes, and for performance reasons.&lt;/p&gt;

&lt;h4 id=&quot;but-how-do-we-use-our-template&quot;&gt;But.. How do we use our template?&lt;/h4&gt;

&lt;p&gt;Chiggity-check this out:&lt;/p&gt;

&lt;div class=&quot;language-js highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;addSimple&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(){&lt;/span&gt;
    &lt;span class=&quot;c1&quot;&gt;// Grab our template&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;t&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;document&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;querySelector&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'template#simple'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;content&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;c1&quot;&gt;// Optional -- Modify template&lt;/span&gt;

    &lt;span class=&quot;c1&quot;&gt;// Clone and add&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;clone&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;document&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;importNode&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;t&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;nb&quot;&gt;document&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;getElementById&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;simple-target&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;appendChild&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;clone&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Simple enough. We’re:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Grabbing a reference to our template’s content.&lt;/li&gt;
  &lt;li&gt;We create a deep-copy clone of the template’s content&lt;/li&gt;
  &lt;li&gt;and then we insert it into our existing DOM.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;simple-template-example&quot;&gt;Simple Template Example&lt;/h3&gt;

&lt;iframe style=&quot;margin: 20px auto; display: block; width: 100%;&quot; src=&quot;http://lug.io/old/examples/web-components-examples/templates/simple/&quot;&gt;&lt;/iframe&gt;

&lt;p&gt;Notice that even though our &lt;code class=&quot;highlighter-rouge&quot;&gt;span&lt;/code&gt; style is defined in our template, it doesn’t affect the existing &lt;code class=&quot;highlighter-rouge&quot;&gt;span&lt;/code&gt; until it is cloned and added. Also, the JS is not executed until the template is added. Even the &lt;code class=&quot;highlighter-rouge&quot;&gt;&amp;lt;image&amp;gt;&lt;/code&gt; isn’t fetched pre-load. Basically, adding the template is like a &lt;em&gt;live&lt;/em&gt; copy &amp;amp; paste into your DOM.&lt;/p&gt;

&lt;h3 id=&quot;can-i-data-bind-data-binding-is-fun&quot;&gt;Can I data-bind? Data-binding is fun!&lt;/h3&gt;

&lt;p&gt;Nope. The closest we can get to this is using DOM manipulation techniques to change our templates to create “fake” data-binding. Here is a slightly more intense example that demonstrates this:&lt;/p&gt;

&lt;div class=&quot;language-html highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;form&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;id=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;data-binding-form&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;onsubmit=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;return addRow()&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;label&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;for=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;name-field&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;Name:&lt;span class=&quot;nt&quot;&gt;&amp;lt;/label&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;input&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;type=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;text&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;name&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;id=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;name-field&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;

    &lt;span class=&quot;nt&quot;&gt;&amp;lt;label&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;for=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;age-field&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;Age:&lt;span class=&quot;nt&quot;&gt;&amp;lt;/label&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;input&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;type=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;text&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;age&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;id=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;age-field&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;

    &lt;span class=&quot;nt&quot;&gt;&amp;lt;label&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;for=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;gender-field&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;Gender:&lt;span class=&quot;nt&quot;&gt;&amp;lt;/label&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;input&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;type=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;text&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;gender&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;id=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;gender-field&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;

    &lt;span class=&quot;nt&quot;&gt;&amp;lt;input&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;type=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;submit&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Submit&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;value=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Submit&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/form&amp;gt;&lt;/span&gt;

&lt;span class=&quot;nt&quot;&gt;&amp;lt;table&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;id=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;persons-table&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;thead&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;tr&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;th&amp;gt;&lt;/span&gt;Name&lt;span class=&quot;nt&quot;&gt;&amp;lt;/th&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;th&amp;gt;&lt;/span&gt;Age&lt;span class=&quot;nt&quot;&gt;&amp;lt;/th&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;th&amp;gt;&lt;/span&gt;Gender&lt;span class=&quot;nt&quot;&gt;&amp;lt;/th&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/tr&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/thead&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;tbody&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;tr&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;td&amp;gt;&lt;/span&gt;Chester Examplefield&lt;span class=&quot;nt&quot;&gt;&amp;lt;/td&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;td&amp;gt;&lt;/span&gt;92&lt;span class=&quot;nt&quot;&gt;&amp;lt;/td&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;td&amp;gt;&lt;/span&gt;Female&lt;span class=&quot;nt&quot;&gt;&amp;lt;/td&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/tr&amp;gt;&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;&amp;lt;!-- Our Row Template --&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;template&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;id=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;table-row&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;tr&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;td&amp;gt;&lt;/span&gt;1&lt;span class=&quot;nt&quot;&gt;&amp;lt;/td&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;td&amp;gt;&lt;/span&gt;2&lt;span class=&quot;nt&quot;&gt;&amp;lt;/td&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;td&amp;gt;&lt;/span&gt;3&lt;span class=&quot;nt&quot;&gt;&amp;lt;/td&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/tr&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/template&amp;gt;&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;&amp;lt;!-- End Row Template --&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/tbody&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/table&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Please Note:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Our template is &lt;em&gt;inside&lt;/em&gt; our table&lt;/li&gt;
  &lt;li&gt;The template’s row is not visible on the screen&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-js highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;// ADD ROW&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;addRow&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;c1&quot;&gt;// Grab our template&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;t&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;document&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;querySelector&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'template#table-row'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;content&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;c1&quot;&gt;// Optional -- Modify template&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;form&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;document&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;querySelector&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'#data-binding-form'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

    &lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;age&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;form&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;querySelector&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;#age-field&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; 		
    &lt;span class=&quot;c1&quot;&gt;//var age = $(&quot;#data-binding-form #age-field&quot;); // Equiv&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;name&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;form&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;querySelector&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;#name-field&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;gender&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;form&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;querySelector&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;#gender-field&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;nx&quot;&gt;t&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;querySelector&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;td:first-child&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;innerHTML&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;t&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;querySelector&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;td:nth-child(2)&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;innerHTML&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;age&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;t&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;querySelector&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;td:last-child&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;innerHTML&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;gender&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;c1&quot;&gt;// Clone/activate template &amp;amp; add to page&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;clone&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;document&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;importNode&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;t&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;#persons-table tr:last&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;after&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;clone&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;   &lt;span class=&quot;c1&quot;&gt;// .after() is using jQuery&lt;/span&gt;

    &lt;span class=&quot;c1&quot;&gt;// Vanilla JS of .after();&lt;/span&gt;
    &lt;span class=&quot;c1&quot;&gt;//var allRows = document.querySelectorAll(&quot;table tr&quot;);&lt;/span&gt;
    &lt;span class=&quot;c1&quot;&gt;//var lastRow = allRows[allRows.length- 1];&lt;/span&gt;

    &lt;span class=&quot;c1&quot;&gt;//lastRow.parentNode.insertBefore(clone, lastRow.nextSibling);&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;// Stop submit event from bubbling up&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Please Note:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;We grab a reference to the template’s content&lt;/li&gt;
  &lt;li&gt;We pull values from our form fields&lt;/li&gt;
  &lt;li&gt;We update the template’s content with our values&lt;/li&gt;
  &lt;li&gt;We clone the &lt;em&gt;now modified&lt;/em&gt; template&lt;/li&gt;
  &lt;li&gt;We add the clone to the page&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;data-binding-example&quot;&gt;“Data-Binding” Example&lt;/h3&gt;

&lt;iframe style=&quot;min-height: 300px; margin: 20px auto; display: block; width: 100%;&quot; src=&quot;http://lug.io/old/examples/web-components-examples/templates/table/&quot;&gt;&lt;/iframe&gt;

&lt;p&gt;You get the idea. Not super intuitive, but it works. This is likely where we’ll see &lt;em&gt;abstractions&lt;/em&gt; like &lt;a href=&quot;https://www.polymer-project.org/1.0/&quot;&gt;polymer&lt;/a&gt; pick up the slack and introduce more developer friendly ways to do data-binding.&lt;/p&gt;

&lt;h3 id=&quot;support&quot;&gt;Support&lt;/h3&gt;

&lt;p&gt;Until we get full cross-browser support, it’s fairly safe to rely on Polyfills for &lt;code class=&quot;highlighter-rouge&quot;&gt;&amp;lt;template&amp;gt;&lt;/code&gt; as they’re simple and performant. Here are some examples of polyfill use:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/webcomponents/webcomponentsjs&quot;&gt;WebComponents.js&lt;/a&gt; (Google-Backed)&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://stackoverflow.com/questions/16055275/html-templates-javascript-polyfills&quot;&gt;Polyfill To Add IE Support&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://jsfiddle.net/brianblakely/h3EmY/&quot;&gt;Example Polyfill Use&lt;/a&gt; (IE6/7 Support)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Even so, unless your target browser support is IE11+, you probably shouldn’t be using &lt;code class=&quot;highlighter-rouge&quot;&gt;&amp;lt;template&amp;gt;&lt;/code&gt; in production. If anyone has any sources that show otherwise, please let me know! (:&lt;/p&gt;

&lt;h2 id=&quot;next-steps&quot;&gt;Next Steps?&lt;/h2&gt;

&lt;p&gt;Templates lay the groundwork for the real meat and potatoes of &lt;a href=&quot;http://webcomponents.org/&quot;&gt;WebComponents&lt;/a&gt;. To fully leverage their power, you may want to check out:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.html5rocks.com/en/tutorials/webcomponents/template/&quot;&gt;Continuing your education on the &lt;code class=&quot;highlighter-rouge&quot;&gt;&amp;lt;template&amp;gt;&lt;/code&gt; tag&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://blog.teamtreehouse.com/creating-reusable-markup-with-the-html-template-element&quot;&gt;Annnddd some more education&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Learning about &lt;a href=&quot;http://www.html5rocks.com/en/tutorials/webcomponents/customelements/&quot;&gt;Custom Elements&lt;/a&gt; (&lt;em&gt;hint&lt;/em&gt; they use templates)&lt;/li&gt;
  &lt;li&gt;Learn more about &lt;a href=&quot;https://remysharp.com/2010/10/08/what-is-a-polyfill&quot;&gt;polyfills&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;resources&quot;&gt;Resources&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;This article in Markdown format &lt;a href=&quot;https://github.com/dannyrb/dannyrb.com/blob/master/_posts/2015-11-05-the-template-tag-a-refresher.markdown&quot;&gt;on GitHub&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;“Simple Template” &lt;a href=&quot;https://github.com/lug-io/WebComponents-Examples/blob/master/templates/simple/index.html&quot;&gt;Example on GitHub&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;“Data-Bind Template” &lt;a href=&quot;https://github.com/lug-io/WebComponents-Examples/blob/master/templates/table/index.html&quot;&gt;Example on GitHub&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Track &lt;a href=&quot;http://caniuse.com/#search=template&quot;&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;&amp;lt;template&amp;gt;&lt;/code&gt;s browser support&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;faq&quot;&gt;FAQ&lt;/h3&gt;

&lt;p&gt;Questions from &lt;a href=&quot;https://www.reddit.com/r/web_design/comments/3rmu57/html5s_template_tag_a_refresher/&quot;&gt;this reddit thread&lt;/a&gt; and comments below will eventually be aggregated here&lt;/p&gt;</content><author><name>Danny Brown</name><email>danny.ri.brown@gmail.com</email></author><category term="web components" /><category term="template" /><category term="polyfills" /><summary type="html">The &amp;lt;template&amp;gt; specification was introduced in 2011, along with the other three specs that make up WebComponents. Since then, &amp;lt;template&amp;gt; has become a part of the W3C Living Document, and has full support in Chrome, Firefox, Opera, Safari, and Android. To boot, Edge has just announced upcoming support. In light of that announcement, let’s refresh (:</summary></entry><entry><title type="html">The Programmer’s Guide to Better SEO: Semantic Markup and HTML5</title><link href="https://dannyrb.com/blog/2015-10-28-the-programmers-guide-to-better-seo-semantic-markup-and-html5/" rel="alternate" type="text/html" title="The Programmer's Guide to Better SEO: Semantic Markup and HTML5" /><published>2015-10-28T00:00:00+00:00</published><updated>2015-10-28T00:00:00+00:00</updated><id>https://dannyrb.com/blog/the-programmers-guide-to-better-seo-semantic-markup-and-html5</id><content type="html" xml:base="https://dannyrb.com/blog/2015-10-28-the-programmers-guide-to-better-seo-semantic-markup-and-html5/">&lt;p&gt;&lt;strong&gt;Disclaimer:&lt;/strong&gt; Content is king. Provide value, make yourself accessible, make your website easy to navigate and easy to understand for your users. Everything detailed below is about Search Engine &lt;em&gt;OPTIMIZATION&lt;/em&gt;, and is not worth a thought until you have something worth optimizing.&lt;/p&gt;

&lt;!--more--&gt;

&lt;hr /&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Search Engines.&lt;/strong&gt; Their goal is to provide quality, up-to-date, and relevant content. To accomplish this, they send out little bots that &lt;a href=&quot;https://www.google.com/insidesearch/howsearchworks/crawling-indexing.html&quot;&gt;crawl and index&lt;/a&gt; trillions of web pages. Bots read these pages to better understand their content, and to help ensure they’re serving up the best possible results. &lt;em&gt;How&lt;/em&gt; they weigh pages is a little bit of a mystery, but one thing is for sure:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Bots need to be able to &lt;em&gt;read&lt;/em&gt; your web pages to properly index them.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Unfortunately, most websites are uneccessarily hard for these bots to read. Because of this, the bots are forced to make “best guesses” about the content; often causing less than optimal page rank (and thereby hurting SEO).&lt;/p&gt;

&lt;h2 id=&quot;semantic-vs-non-semantic&quot;&gt;Semantic vs. Non-Semantic&lt;/h2&gt;

&lt;p&gt;Humans can see web page styles. This allows us to group content and understand each element’s context &lt;em&gt;regardless of the underlying DOM elements&lt;/em&gt;. Robots lack this ability. When a bot reads a web page, it ignores all of the styling and uses the HTML tags to understand what it’s looking at.&lt;/p&gt;

&lt;figure class=&quot;w-3 pull-l&quot;&gt;
	&lt;img src=&quot;/assets/img/blog/2015/10/28/non-semantic-layout.png&quot; alt=&quot;a layout riddled with div elements&quot; /&gt;
&lt;/figure&gt;

&lt;h3 id=&quot;non-semantic&quot;&gt;Non-Semantic&lt;/h3&gt;
&lt;p&gt;With all of the styling ripped away, and using non-semantic elements (like &lt;code class=&quot;highlighter-rouge&quot;&gt;&amp;lt;span&amp;gt;&lt;/code&gt; and &lt;code class=&quot;highlighter-rouge&quot;&gt;&amp;lt;div&amp;gt;&lt;/code&gt;), this is what a bot would see. Going off of this structure alone, the bot is forced to make “best guesses” about the context of the page’s content.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Do you know where to find the unique content on this page? Do you know which content isn’t relevant?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I’m sure you can make some educated guesses. But it’s hard to know for sure.&lt;/p&gt;

&lt;figure class=&quot;w-3 pull-r&quot;&gt;
	&lt;img src=&quot;/assets/img/blog/2015/10/28/semantic-layout.png&quot; alt=&quot;a more semantic layout&quot; /&gt;
&lt;/figure&gt;

&lt;h3 id=&quot;semantic&quot;&gt;Semantic&lt;/h3&gt;
&lt;p&gt;By using semantic elements, how and where to find the different kinds of information on our web page becomes much clearer. Bots can now find:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Content unique to our page&lt;/li&gt;
  &lt;li&gt;Where one article stops and another begins&lt;/li&gt;
  &lt;li&gt;The components that make up each article&lt;/li&gt;
  &lt;li&gt;Etc.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We can use semantic elements (basically “more descriptive &lt;code class=&quot;highlighter-rouge&quot;&gt;&amp;lt;div&amp;gt;&lt;/code&gt; tags) to provide context and clarity. But what elements do we have at our disposal? What are the rules that govern when and how we should use them?&lt;/p&gt;

&lt;h2 id=&quot;being-semantically-correct&quot;&gt;Being Semantically Correct&lt;/h2&gt;

&lt;p&gt;There are two different kinds of semantic elements: &lt;a href=&quot;http://blog.teamtreehouse.com/use-html5-sectioning-elements&quot;&gt;Sectioning Elements&lt;/a&gt; and.. uh.. &lt;a href=&quot;http://www.w3schools.com/tags/default.asp&quot;&gt;All of the other ones&lt;/a&gt;. Where Sectioning Elements are more descriptive versions of the classic &lt;code class=&quot;highlighter-rouge&quot;&gt;&amp;lt;div&amp;gt;&lt;/code&gt;, and the remaining elements imply or add additional behavior (&lt;code class=&quot;highlighter-rouge&quot;&gt;&amp;lt;a href=&quot;&quot;&amp;gt;&amp;lt;/a&amp;gt;&lt;/code&gt;, &lt;code class=&quot;highlighter-rouge&quot;&gt;&amp;lt;p&amp;gt;&amp;lt;/p&amp;gt;&lt;/code&gt;, etc.)&lt;/p&gt;

&lt;h3 id=&quot;sectioning-elements&quot;&gt;Sectioning Elements&lt;/h3&gt;

&lt;p&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;&amp;lt;main&amp;gt;&lt;/code&gt; &lt;code class=&quot;highlighter-rouge&quot;&gt;&amp;lt;article&amp;gt;&lt;/code&gt; &lt;code class=&quot;highlighter-rouge&quot;&gt;&amp;lt;section&amp;gt;&lt;/code&gt; &lt;code class=&quot;highlighter-rouge&quot;&gt;&amp;lt;nav&amp;gt;&lt;/code&gt; &lt;code class=&quot;highlighter-rouge&quot;&gt;&amp;lt;aside&amp;gt;&lt;/code&gt; &lt;code class=&quot;highlighter-rouge&quot;&gt;&amp;lt;header&amp;gt;&lt;/code&gt; &lt;code class=&quot;highlighter-rouge&quot;&gt;&amp;lt;footer&amp;gt;&lt;/code&gt; &lt;code class=&quot;highlighter-rouge&quot;&gt;&amp;lt;address&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;For sectioning elements, there are only a few non-obvious rules regarding their usage:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;&amp;lt;main&amp;gt;&lt;/code&gt; Represents the main content of the page. There should only be one. You should not place &amp;lt;main&amp;gt; inside another semantic element.&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;&amp;lt;article&amp;gt;&lt;/code&gt; Should make sense if distributed outside the context of the page. Can contain other articles. Should have a heading.&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;&amp;lt;aside&amp;gt;&lt;/code&gt; Much like a &lt;a href=&quot;https://en.wikipedia.org/wiki/Aside&quot;&gt;play’s aside&lt;/a&gt;, content in an aside breaks away from the normal flow. It is usually related, and expands on something. Commonly contains &lt;code class=&quot;highlighter-rouge&quot;&gt;&amp;lt;figures&amp;gt;&lt;/code&gt;, groups of &lt;code class=&quot;highlighter-rouge&quot;&gt;&amp;lt;nav&amp;gt;&lt;/code&gt;s and quotes.&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;&amp;lt;address&amp;gt;&lt;/code&gt; Should contain the author’s contact information. Author of… the website, of the article, of the comment, etc.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The remaining sectioning elements can be used any number of ways so long as their meaning is preserved. For example: your webpage can have a &lt;code class=&quot;highlighter-rouge&quot;&gt;&amp;lt;footer&amp;gt;&lt;/code&gt;, but an &lt;code class=&quot;highlighter-rouge&quot;&gt;&amp;lt;artical&amp;gt;&lt;/code&gt; can also have a &lt;code class=&quot;highlighter-rouge&quot;&gt;&amp;lt;footer&amp;gt;&lt;/code&gt;.&lt;/p&gt;

&lt;h4 id=&quot;still-confused&quot;&gt;Still Confused?&lt;/h4&gt;
&lt;p&gt;&lt;a href=&quot;https://teamtreehouse.com/&quot;&gt;Tree House&lt;/a&gt; has a great article that &lt;a href=&quot;http://blog.teamtreehouse.com/use-html5-sectioning-elements&quot;&gt;examines each sectioning element&lt;/a&gt;, and HTML5 Doctor has a &lt;a href=&quot;http://html5doctor.com/downloads/h5d-sectioning-flowchart.png&quot;&gt;great flow-chart&lt;/a&gt; that walks you through picking the right element.&lt;/p&gt;

&lt;h3 id=&quot;other-semantic-elements&quot;&gt;Other Semantic Elements&lt;/h3&gt;

&lt;p&gt;Most of HTML’s elements are semantic, but arguably the most important ones (in order) are:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Title: &lt;code class=&quot;highlighter-rouge&quot;&gt;&amp;lt;title&amp;gt;&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;Headers &lt;code class=&quot;highlighter-rouge&quot;&gt;&amp;lt;h1&amp;gt;&lt;/code&gt; through &lt;code class=&quot;highlighter-rouge&quot;&gt;&amp;lt;h6&amp;gt;&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;Hyperlinks &lt;code class=&quot;highlighter-rouge&quot;&gt;&amp;lt;a&amp;gt;&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;Emphasis &lt;code class=&quot;highlighter-rouge&quot;&gt;&amp;lt;b&amp;gt;&lt;/code&gt; and &lt;code class=&quot;highlighter-rouge&quot;&gt;&amp;lt;strong&amp;gt;&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Google bots are reading your web page trying to figure out &lt;a href=&quot;https://support.google.com/webmasters/answer/35255?hl=en&quot;&gt;which keywords best correlate with your content&lt;/a&gt;. Like humans, they look to the &lt;code class=&quot;highlighter-rouge&quot;&gt;&amp;lt;title&amp;gt;&lt;/code&gt; of the document, and at the main headings (&lt;code class=&quot;highlighter-rouge&quot;&gt;&amp;lt;h1&amp;gt;&lt;/code&gt;, &lt;code class=&quot;highlighter-rouge&quot;&gt;&amp;lt;h2&amp;gt;&lt;/code&gt;, and &lt;code class=&quot;highlighter-rouge&quot;&gt;&amp;lt;h3&amp;gt;&lt;/code&gt;). They’ll likely assume emphasized and bold words are important, and that any other web pages you link to are related to your content.&lt;/p&gt;

&lt;p&gt;It is less common to see these elements missused. Switching out an &lt;code class=&quot;highlighter-rouge&quot;&gt;&amp;lt;aside&amp;gt;&lt;/code&gt; with an &lt;code class=&quot;highlighter-rouge&quot;&gt;&amp;lt;article&amp;gt;&lt;/code&gt; makes no visual difference, but swap a hyperlink &lt;code class=&quot;highlighter-rouge&quot;&gt;&amp;lt;a&amp;gt;&lt;/code&gt; for &lt;code class=&quot;highlighter-rouge&quot;&gt;&amp;lt;span&amp;gt;&lt;/code&gt; and you will immediately notice.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;&amp;lt;aside&amp;gt;&lt;/code&gt; == Ignorance ==&amp;gt; &lt;code class=&quot;highlighter-rouge&quot;&gt;&amp;lt;article&amp;gt;&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;blockquote&gt;
  &lt;p&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;&amp;lt;a&amp;gt;&lt;/code&gt; == Willfull Ignorance ==&amp;gt; &lt;code class=&quot;highlighter-rouge&quot;&gt;&amp;lt;span&amp;gt;&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3 id=&quot;still-confused-1&quot;&gt;Still Confused?&lt;/h3&gt;

&lt;p&gt;&lt;a href=&quot;http://html5doctor.com/&quot;&gt;HTML5Doctor&lt;/a&gt; has a list of all HTML elements, as well as descriptions and examples of how and when to use them.&lt;/p&gt;

&lt;h2 id=&quot;faq&quot;&gt;FAQ&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Why not &lt;code class=&quot;highlighter-rouge&quot;&gt;&amp;lt;insert-any-name-here&amp;gt;&lt;/code&gt; elements?&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Actually… The &lt;a href=&quot;http://www.w3.org/wiki/WebComponents/&quot;&gt;newest W3C spec for WebComponents&lt;/a&gt; leaves room for programmers to create their own DOM Elements. Projects like &lt;a href=&quot;https://www.polymer-project.org/1.0/&quot;&gt;Google’s Polymer&lt;/a&gt; seeks to implement the new spec, and groups like &lt;a href=&quot;http://webcomponents.org/&quot;&gt;webcomponents.org&lt;/a&gt; are helping facilitate discussion and education on the topic.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Why should I take the time to care about Semantic Markup?&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Going through your application and replacing lame duck &lt;code class=&quot;highlighter-rouge&quot;&gt;&amp;lt;div&amp;gt;&lt;/code&gt;s with cool, hip-happenin’ Sectioning Elements is a quick process. It nets you increased SEO, makes your website more accessible to modern screen readers, and you’re creating easier to maintain code.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;What does a google bot look like?&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;figure class=&quot;w-3&quot; style=&quot;margin: 0 auto;&quot;&gt;
	&lt;img src=&quot;/assets/img/blog/2015/10/28/google-bot.png&quot; alt=&quot;not an actual google bot&quot; /&gt;
&lt;/figure&gt;

&lt;h2 id=&quot;next-steps&quot;&gt;Next Steps&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;MicroData &amp;amp; &lt;a href=&quot;http://www.schema.org/&quot;&gt;Schema.org&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Semantic Markup on steroids. MicroData introduces additional tags search engines can use to pull specific data from your page. Not a part of the W3C spec, but standardized by the major search engines. &lt;a href=&quot;http://blog.teamtreehouse.com/writing-semantic-microformats-amp-microdata-in-html-markup&quot;&gt;Here is a treehouse post on MicroData&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;MetaData &amp;amp; Social Share&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Your website’s metadata is important. It tells social websites how to &lt;a href=&quot;http://www.quicksprout.com/2013/03/25/social-media-meta-tags-how-to-use-open-graph-and-cards/&quot;&gt;format specific pages when they’re shared&lt;/a&gt;, it helps to further define your &lt;a href=&quot;http://webdesign.tutsplus.com/articles/meta-tags-and-seo--webdesign-9683&quot;&gt;page’s keywords and relevance&lt;/a&gt; for SEO, and &lt;a href=&quot;http://secretsaucehq.com/blog/social-media/the-ultimate-guide-to-social-media-meta-tags/&quot;&gt;so&lt;/a&gt;. &lt;a href=&quot;https://github.com/antistatique/electron2015/issues/3&quot;&gt;much&lt;/a&gt;. &lt;a href=&quot;http://blog.hubspot.com/marketing/seo-tactics-2015&quot;&gt;more&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;resources--more-reading&quot;&gt;Resources &amp;amp; More Reading:&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;Overview: &lt;a href=&quot;http://www.w3schools.com/html/html5_semantic_elements.asp&quot;&gt;W3Schools Semantic Elements&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;In-Depth: &lt;a href=&quot;http://html5doctor.com/lets-talk-about-semantics/&quot;&gt;HTML5 Doctor: Let’s Talk Semantics&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Official: &lt;a href=&quot;http://www.w3.org/TR/html5/dom.html#dom&quot;&gt;W3C&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</content><author><name>Danny Brown</name><email>danny.ri.brown@gmail.com</email></author><category term="seo" /><category term="html5" /><category term="semantic" /><summary type="html">Disclaimer: Content is king. Provide value, make yourself accessible, make your website easy to navigate and easy to understand for your users. Everything detailed below is about Search Engine OPTIMIZATION, and is not worth a thought until you have something worth optimizing.</summary></entry></feed>