jqueryruby-on-railsdouble-click-advertising

Is it possible to track clicks on DoubleClick ads in our Rails app?


We are currently serving third party DoubleClick ads on our Ruby on Rails app for a client, and they're asking us to deliver specific click data that requires us to internally log clicks to their script tags (so we can associate a user with an ad click). Is this possible?

They seem to have the idea that it is industry standard, but it is tough to find proper documentation without access to any internal DoubleClick tools.

Thanks!


Solution

  • Its actually pretty straight forward. I suggest you to create a new super simple project and recreate what im showing below to see that it works and than find a way to drop that into your project (since you haven't provided there any informations/examples).

    First, migrate a specific integer to your model, called 'click'. Add association, has_many, belongs_to.

    Create a new model ->

    rails g model Click clickcounter:integer
    

    Create a new controller ->

    rails g controller Clicks
    

    inside the ClicksController:

    def create
    
            @your_ad = Ad.find(params[:ad_id])
    
            @click = @your_ad.clicks.new(ip_address: request.ip)
    
            @click.save
    
            redirect_to @your_ad.url
    
    
        end
    end
    

    then, add either a form as a wrapper around your add via div, or add a hidden link_to.

    Now since your 'Ads' are probably not a model itself, but instead a simple link, you could also simply create the click model with an integer alone and count the clicks without any association. You could link the method to devise (if you are using it) and then add name, ip address at the admin dashboard.

    Greetings!