Domanda

I have something similar to twitter's feeds where we load it in real-time. How do i track how many people have seen a tweet? I am not talking about if you go to domain.com/post/32434 and that loads a status. I am talking about AJAX real-time query where one post is being loaded one after the other.

Will Google Analytics or Charbeat have anything that will help fulfill this need for me?

È stato utile?

Soluzione

Why not managing your own counter in the database?

I don't really know your criteria, but let say you basically want to count how many times a given tweet was loaded.

Very quickly, I could think of this: The table:

CREATE TABLE tweets_loads(ID_TWEET INT NOT NULL, LOADS BIGINT NOT NULL DEFAULT 0, PRIMARY KEY `ID_TWEET`) ENGINE=InnoDB;

The query at each ajax request:

INSERT INTO tweets_loads (ID_TWEET, LOADS) VALUES (myTweetId, 1)
ON DUPLICATE KEY UPDATE LOADS = LOADS + 1;

(Assuming mysql)

Run it from php and that's it... Up to you then to check competition between inserts though, but in theory mysql should handle it just well...

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top