Videos
I sent a package to Canada from the us in early March. Customer says it’s still not there. Tracking says it was “handed the last mile” on the 8th of March. Pirate ship says that means the local carrier got the package. Unless the customer can find the package I’m going to suggest they open an Etsy case to get refunded and then just order again. But does the weird tracking number for simple export rate count as “tracking” as far as Etsy is concerned? I want this to be covered under the sellers protection. Thanks!
i create a label on pirateship for an international shipment. what do i put on paypal forrecord? do i use the usps tracking on the label, or the pirate ship tracking number (start with AHOY...)?
I struggled with this for a while aswell. I was able to mostly get it to work.
Your second method won't do what you want because it is tracking something else. Instead of tracking how many views the post has, it tracks 1 single view. It tracks the view that was used to create the post. It does this by attaching the view to the model.
Your first method is close to what you want. However all the events you store arent actually storing the visit id in them, as events do not do this by default. You need to add the visit_id yourself, usually into the properties variable of the Event.
Here is you would need to do:
First you would place the tracking code in the controller(most likely in the "show" portion):
if not Ahoy::Event.where(name: "Post:#{@post.id}", properties: current_visit.visit_token).exists?
ahoy.track "Post:#{@post.id}", current_visit.visit_token
end
By placing the post id in the name, as well as the text "Post:" it will let it track only views to the Post controller, with the specific id. visit_tokens are unique to a user, and the expire after a given configured time(default 8 hours) so it will only track repeat users if they view the page after the configured time
Next to read the view count you can place something like this in the controller wherever you want to see views(in show, edit, etc):
@views = Ahoy::Event.where(name: "Post:#{@post.id}").count
And then in your views you can just use @views
Note: You aren't supposed to set :properties as a single value, but rather its supposed to hold a hash. However I was not able to figure out how to get it to work.
Further to @announceractor's answer, you do not need to store the visit_token with your event; Ahoy::Event already belongs to Ahoy::Visit. And the event name probably shouldn't contain the post ID - it's better to keep event names generic and use the properties hash to store the event's unique properties. Ahoy provides a where_properties convenience method to query the event property hash. Here's how I do it (in an after_action on Page#show):
def track_view
if not Ahoy::Event.where(name: "Page view").where_properties(page_id: @page.id, visit_id: current_visit.id).exists?
ahoy.track("Page view", {page_id: @page.id})
end
end