Skip to content

Instantly share code, notes, and snippets.

@alexandraj777
Created October 27, 2016 22:03
Show Gist options
  • Save alexandraj777/0d1f0629acce0f7303b553b2c4173af6 to your computer and use it in GitHub Desktop.
Save alexandraj777/0d1f0629acce0f7303b553b2c4173af6 to your computer and use it in GitHub Desktop.
Track tumblr blog post views with Segment's analytics.js
// This snippet goes in your tumblr html theme right after you've loaded the analytics.js library.
// Use this to replace analytics.page() in the generic analytics.js library setup code.
// Homepage blog views will be tracked as analytics.page("Blog", "Home"),
// whereas individual post views will be tracked as analytics.page("Blog", "Post") with metadata.
{block:PermalinkPage}
{block:Posts}
{block:Text}
{block:Title}
analytics.page("Blog", "Post", {
postTitle: "{PlaintextTitle}",
postId: {PostID}
});
{/block:Title}
{/block:Text}
{/block:Posts}
{/block:PermalinkPage}
{block:IndexPage}
analytics.page("Blog", "Home");
{/block:IndexPage}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment