{"id":18736268,"url":"https://github.com/decaf-dev/obsidian-view-count","last_synced_at":"2025-04-12T19:21:59.478Z","repository":{"id":223072912,"uuid":"759252541","full_name":"decaf-dev/obsidian-view-count","owner":"decaf-dev","description":"Add view count tracking to your Obsidian vault","archived":false,"fork":false,"pushed_at":"2024-09-18T01:14:45.000Z","size":2439,"stargazers_count":17,"open_issues_count":4,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-10T13:11:39.327Z","etag":null,"topics":["analytics","obsidian-md","obsidian-notes","obsidian-plugin","obsidian-vault","svelte","tracking","view-count"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/decaf-dev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"custom":"https://ko-fi.com/decaf_dev"}},"created_at":"2024-02-18T04:06:57.000Z","updated_at":"2025-02-01T03:55:50.000Z","dependencies_parsed_at":"2024-03-01T21:29:49.734Z","dependency_job_id":"d3ee669c-9ff2-4f14-9625-679c2082d51c","html_url":"https://github.com/decaf-dev/obsidian-view-count","commit_stats":null,"previous_names":["trey-wallis/obsidian-view-count","decaf-dev/obsidian-view-count"],"tags_count":33,"template":false,"template_full_name":"obsidianmd/obsidian-sample-plugin","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/decaf-dev%2Fobsidian-view-count","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/decaf-dev%2Fobsidian-view-count/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/decaf-dev%2Fobsidian-view-count/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/decaf-dev%2Fobsidian-view-count/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/decaf-dev","download_url":"https://codeload.github.com/decaf-dev/obsidian-view-count/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248618715,"owners_count":21134285,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["analytics","obsidian-md","obsidian-notes","obsidian-plugin","obsidian-vault","svelte","tracking","view-count"],"created_at":"2024-11-07T15:19:56.905Z","updated_at":"2025-04-12T19:21:59.451Z","avatar_url":"https://github.com/decaf-dev.png","language":"TypeScript","readme":"# Obsidian View Count\n\n![Obsidian Downloads](https://img.shields.io/badge/dynamic/json?logo=obsidian\u0026color=%23483699\u0026label=downloads\u0026query=%24%5B%22view-count%22%5D.downloads\u0026url=https%3A%2F%2Fraw.githubusercontent.com%2Fobsidianmd%2Fobsidian-releases%2Fmaster%2Fcommunity-plugin-stats.json)\n\nView count is an [Obsidian.md](https://obsidian.md) plugin for desktop and mobile. It allows you to track the view count for each file in your vault.\n\n## Table of contents\n\n-   [Videos](#videos)\n-   [Installation](#installation)\n-   [Usage](#usage)\n-   [Dataview](#dataview)\n-   [API](#api)\n-   [Settings](#settings)\n-   [License](#license)\n\n## Videos\n\nBasic plugin usage\n\n\u003cvideo src=\"https://github.com/decaf-dev/obsidian-view-count/assets/40307803/e51fec6b-2549-4c3a-bff3-65f6d3009671\" controls=\"controls\" style=\"max-width: 100%;\"\u003e\n  Your browser does not support the video tag.\n\u003c/video\u003e\n\n\u003cbr/\u003e\n\nThe [sync view count to frontmatter](#sync-view-count-to-frontmatter) setting\n\n\u003cvideo src=\"https://github.com/decaf-dev/obsidian-view-count/assets/40307803/2e245b7d-a4f6-4e39-b115-6f0de71e7cba\" controls=\"controls\" style=\"max-width: 100%;\"\u003e\n  Your browser does not support the video tag.\n\u003c/video\u003e\n\n\u003cbr/\u003e\n\nThe [view count type](#view-count-type) setting\n\n\u003cvideo src=\"https://github.com/decaf-dev/obsidian-view-count/assets/40307803/ba3a4317-5307-40db-8bbe-75d686ae0e4f\" controls=\"controls\" style=\"max-width: 100%;\"\u003e\n  Your browser does not support the video tag.\n\u003c/video\u003e\n\n## Installation\n\n1. In Obsidian, open **Settings**\n2. Go to **Community plugins**\n3. Select **Browse**\n4. Search for **View Count** by **DecafDev**\n5. Select **Install**\n6. Then select **Enable**\n\n## Usage\n\nOnce you enable the plugin, view count data will start being tracked. You can see the view count on desktop in the status bar in the bottom righthand corner.\n\nThere are 2 types of view count. [View count type](#view-count-type)\n\nIf you would like to view the view count on mobile, you will need to enable the [Sync view count to frontmatter](#sync-view-count-to-frontmatter) setting.\n\n### View count view\n\nBy default, the plugin will add a view to the sidebar called **View count**. You may access this view by opening the sidebar and clicking on the eye icon.\n\nIf the view is not open, you may run **Open view count view** from the command palette.\n\nThere are 2 different lists within the view count:\n\n-   A list of the most viewed notes in your vault sorted in descending order. Click on the eye icon to see this list.\n\n-   A list of the notes with the highest trending weight sorted in descending order. Click on the trending icon to see this list.\n\n## Dataview\n\nYou may dynamically query view count data using the [Dataview plugin](https://obsidian.md/plugins?id=dataview)\n\n### Example 1 - Query view count using Dataview\n\nIf you have **Sync view count to frontmatter** enabled you may query the view count property from the frontmatter of each note.\n\n````markdown\n```dataview\nTABLE view-count AS \"View Count\" SORT view-count DESC LIMIT 10\n```\n````\n\nLet's analyze this codeblock:\n\n1. Render a table using the [Dataview Query Language](https://blacksmithgu.github.io/obsidian-dataview/queries/structure/)\n2. Query the `view-count` property in each note\n3. Display that property in a column called \"View Count\"\n4. Sort the results in descending order (highest to lowest)\n5. Limit the results to 10 notes\n\n### Example 2 - Query trending notes from the last 7 days using DataviewJS\n\n````markdown\n```dataviewjs\nconst plugin = this.app.plugins.plugins[\"view-count\"];\nconst cache = plugin.viewCountCache;\n\nconst TIME_PERIOD = \"7-days\";\n\ndv.table([\"Name\", \"Trending Weight\"],\n    dv.pages().sort(p =\u003e cache.getTrendingWeight(p.file, TIME_PERIOD), \"desc\")\n        .map(p =\u003e [p.file.name, cache.getTrendingWeight(p.file, TIME_PERIOD)])\n\t        .slice(0,10)\n);\n```\n````\n\nLet's analyze this codeblock:\n\n1. Render a table using the [DataviewJS](https://blacksmithgu.github.io/obsidian-dataview/api/intro/)\n2. Display 2 columns in the table: \"Name\" and \"Trending Weight\"\n3. Query all markdown files\n4. Sort the files based on the trending weight in descending order (highest to lowest)\n5. Format an array of data that includes object with just the file name and the trending weight\n6. Limit the results to 10 notes\n\nThe time period can be updated with various values. See the [time period](#time-period) section below.\n\n## API\n\nThe view count plugin exposes an API that can be used to fetch the view count or trending weight for any file.\n\nTo start, you need to access the view count cache.\n\n```javascript\n//Get the view count plugin\nconst plugin = this.app.plugins.plugins[\"view-count\"];\n\n//Get the view count cache\nconst cache = plugin.viewCountCache;\n```\n\nThen you can use the cache to get a view count or trending weight.\n\n```javascript\n//Get the trending weight\nconst weight = cache.getTrendingWeight(file, timePeriod);\nconsole.log(weight);\n//output: 22\n\n//Get the view count\nconst viewCount = cache.getViewCount(file);\nconsole.log(viewCount);\n//output: 5\n```\n\nHere are the typescript definitions for these functions:\n\n```javascript\ngetViewCount: (file: TFile) =\u003e number;\ngetTrendingWeight: (file: TFile, timePeriod: TimePeriod) =\u003e number;\n```\n\n### Time period\n\nThe `getTrendingWeight` function accepts a time period.\n\nHere are the options:\n\n| Value      | Description                           |\n| ---------- | ------------------------------------- |\n| `3-days`   | The last 3 days                       |\n| `7-days`   | The last 7 days                       |\n| `14-days`  | The last 14 days                      |\n| `30-days`  | The last 30 days                      |\n| `today`    | The start of the current day          |\n| `week`     | The start of the week i.e. Sunday     |\n| `week-iso` | The start of the iso week i.e. Monday |\n| `month`    | The start of the month e.g. January 1 |\n\n## Settings\n\n### Count method\n\nThe method used to calculate view counts. This can be the total number of times a file has been opened or the unique days a file has been opened.\n\nFor example, consider a user that opened a file 3 times in 1 day. Using `Total times opened` the view count would be 3. However, using `Unique days opened` the view count would be 1.\n\nA unique day is considered an opening of a file after 12 am local time.\n\n### Excluded paths\n\nThe folder paths that should be excluded from view count tracking. Please separate individual paths by commas e.g. `folder1,folder2`\n\n### Sync view count\n\nThe view count for all files is stored in a JSON file located in the Obsidian configuration folder e.g. `.obsidian/view-count.json`. When `Sync view count` is enabled, the plugin will add a view count property to all notes and continuously update them to match the values stored in the JSON file.\n\nEnabling this setting makes view count visible on mobile devices.\n\n### Skip new notes\n\nWhen enabled, new notes will not have a view count property added upon creation. However, if `Sync View Count` is enabled, a property will be added when the note is opened.\n\n### Property name\n\nThe name of the property that the view count will be stored in.\n\n\u003e [!WARNING]\n\u003e Please rename the existing view count property before updating this value. You can rename the existing property using the **rename** option in the **All Properties** view in the right sidebar.\n\n### Templater delay\n\nThe time to wait in milliseconds before adding a view count property to a new note. You should increase this value if you're using the [Templater plugin](https://github.com/SilentVoid13/Templater) and the template applied during new note creation is being overwritten.\n\n## License\n\nView Count is distributed under [MIT License](https://github.com/decaf-dev/obsidian-view-count/blob/master/LICENSE)\n","funding_links":["https://ko-fi.com/decaf_dev"],"categories":["TypeScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdecaf-dev%2Fobsidian-view-count","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdecaf-dev%2Fobsidian-view-count","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdecaf-dev%2Fobsidian-view-count/lists"}