Closed atd closed 5 years ago
seems travis is still using an old .travis.yml - guess the failure should be fixed in master. merging... @atd thanks for your valuable contribution!
I updated my Gemfile to use the version of the gem with this commit. I then attempted to add a proc to the controller action associated with my lead submission thank you page:
tracker do |t|
t.google_global :conversion, { send_to: 'AW-nnnnnnnnn/the-code-google-ads-gave-me', value: 100.0, currency: 'USD' }
end
When I triggered the thank you page, an error was raised in my production.log that says (edited):
NameError (uninitialized constant Rack::Tracker::GoogleGlobal::Conversion):
activesupport (4.2.5) lib/active_support/inflector/methods.rb:263:in `const_get'
activesupport (4.2.5) lib/active_support/inflector/methods.rb:263:in `block in constantize'
activesupport (4.2.5) lib/active_support/inflector/methods.rb:259:in `each'
activesupport (4.2.5) lib/active_support/inflector/methods.rb:259:in `inject'
activesupport (4.2.5) lib/active_support/inflector/methods.rb:259:in `constantize'
activesupport (4.2.5) lib/active_support/core_ext/string/inflections.rb:66:in `constantize'
/data/genlighten_2017/shared/bundled_gems/ruby/2.2.0/bundler/gems/rack-tracker-3023a5cb3f51/lib/rack/tracker/handler.rb:33:in `block in events'
/data/genlighten_2017/shared/bundled_gems/ruby/2.2.0/bundler/gems/rack-tracker-3023a5cb3f51/lib/rack/tracker/handler.rb:33:in `map'
/data/genlighten_2017/shared/bundled_gems/ruby/2.2.0/bundler/gems/rack-tracker-3023a5cb3f51/lib/rack/tracker/handler.rb:33:in `events'
In short, the 'conversion' event doesn't seem to be recognized.
Any suggestions what I'm doing wrong here? Could someone please provide sample syntax I can put in my controller to trigger a conversion event when my thank_you page loads?
Thank you!
--Dean
good point. maybe @atd can you add an usage example to the readme?
I think it should be something like:
tracker do |t|
t.google_global :event, { action: 'convesion', label: 'Github', value: 5 }
end
look at the supported params: https://github.com/railslove/rack-tracker/pull/126/files#diff-8c96bad81146eddcac1965e5645e68f3R15
@genlighten you should use the :event
parameter as @bumi suggest and it is gathered in the documentation https://support.google.com/google-ads/answer/7548399?hl=en#global_site_tag
I appreciate these suggestions very much! I've implemented them and now, when I view source on the thank_you page, I see this gtag syntax appearing:
gtag('event', 'conversion', {"event_label":"FGRjCJXp6JUBENWlvNcD","value":100.0});
This differs slightly from the code the google adwords docs want me to display on my thank_you page:
gtag('event', 'conversion', {'send_to': 'AW-nnnnnnnnn/FGRjCJXp6JUBENWlvNcD'});
Is event_label instead of 'send_to' and the lack of the AW-code going to be recognized by google?
Thanks,
--Dean
@genlighten you should use the right params:
gtag('event', 'conversion', {send_to: 'AW-nnnnnnnnn/the-code-google-ads-gave-me', value: 100.0, currency: 'USD' });
But they might be filtered and have to be added at https://github.com/railslove/rack-tracker/blob/master/lib/rack/tracker/google_global/google_global.rb#L14
I updated my code to include the send_to parameter the way the Google docs request:
tracker do |t|
t.google_global :event, { action: 'conversion', send_to: 'AW-nnnnnnnnn/FGRjCJXp6JUBENWlvNcD', value: 100.0, currency: 'USD' }
end
Now when I trigger my thank_you page, the code that is generated and appears with view-source looks like this:
gtag('event', 'conversion', {"value":100.0});
In other words, my attempt to send the send_to parameter was ignored, as was the currency parameter. Perhaps as you suggested, it was somehow filtered out?
Digging into the gtag.js parameter reference, I find this "send_to" as a control parameter, but I don't find "conversion" as an event parameter.
Any suggestions on where to head next? And what would I potentially need to add to line 14, per your concluding comment above?
Thank you!
--Dean
@genlighten
The "conversion" is not filtered because it is the action
of the event
I would suggest you to:
bundle
to use your repo with your modifications https://bundler.io/guides/git.html Now you would have your stuff working!all the google_global related code can be found here: https://github.com/railslove/rack-tracker/tree/master/lib/rack/tracker/google_global - guess mainly you want to look into the parameters as @atd said.
https://developers.google.com/analytics/devguides/collection/gtagjs/events