9.4 Search Referencing and Analytics - caligrafy/caligrafy-quill GitHub Wiki

For any application today to be searchable through search engines like Google for example, it needs to be tagged properly. Caligrafy provides you with some helper methods and out-of-the-box views that help you reference your application pages properly.

Metadata

Having adequate metadata and structured data is key for search engines to know more about the content of your pages. Caligrafy comes prepackaged with methods and view modules that could help you achieve that easily.

Learn more about Metadata Definition here

Keywords

The most basic metadata that your pages need to have are keywords. Search engine algorithms rely on the keywords metadata to ultimately display your pages in the appropriate context. In order to set the keywords for your application, Caligrafy provides a core helper method keywords(String keywords) that takes string of keywords separated by comas.

In order to set the keywords, you could either call the keywords() methods from the controller handling the page or if you want to set the same keywords for all your pages, you can call the method once from /application/config/config.php.

keywords('keyword1, keyword2, keyword3');

if you are using the master views or the view modules provided by Caligrafy, then all you need to do is activate the metadata by sending it to the view and the defined keywords will be sent along with the other metadata.

Learn more about Metadata Definition here

Linking your application to Google

Caligrafy uses Google as the primary engine for search referencing out-of-the-box. When you create a Site property in the Google Admin Console, you first need to verify that the site belongs to you. For that, Google usually asks you to include a piece of code in your pages. With Caligrafy, you don't have to worry about that. If you are using the master views or the view modules provided by Caligrafy, you need to do 2 things:

1- Add the google-site-verification code to your metadata

Learn more about Metadata Definition here

2- Send the metadata to the view

use Caligrafy\Controller;

class MyController extends Controller {
    public function index()
    {
       return view('default/index', array('metadata' => metadata());
    }
}

Linking your application with Google Analytics

If you want to connect your application with Google Analytics to get more insights on your application usage, you can do this very easily with Caligrafy from the moment you create a Google Analytics account and that you get a Google Analytics ID. You will be able to activate analytics in 2 steps:

1- Add the Google Analytics ID in the .env file

For Google Analytics to work, your application needs to be on a production server. In the .env, the APP_ENV must be set to production, otherwise the analytics snippet code will not be included.

2- Activate analytics for the pages that you want to track by sending the activation to the view

use Caligrafy\Controller;

class MyController extends Controller {
    public function index()
    {
       return view('default/index', array('metadata' => metadata(),'google_analytics' => true));
    }
}



This the end of the documentation and the beginning of your journey!

⚠️ **GitHub.com Fallback** ⚠️