ipunkt / laravel-analytics

Analytics tracking package for Laravel
MIT License
263 stars 54 forks source link

Analytics::setCampaign() not rendering ga('set', 'campaignName'...) when set prior to redirect #37

Closed FOOLanceProd closed 7 years ago

FOOLanceProd commented 7 years ago

Happy New Year! Thanks for a well thought out solution.

It may be by design, or due to a limitations in redirects and sessions, but Analytics::setCampaign() does not render ga('set', 'campaignName'...) on a the final redirected page when Analytics::setCampaign() is called prior to a "return Redirect::to()" call.

Note that Analytics::trackEvent() does work if called prior to a "return Redirect::to()" call. The final redirected page does have ga('send', 'event',...).

Best regards,

Keith

rokde commented 7 years ago

Hi Keith,

this is by design. You can not track a campaign or other things through redirects. The event tracking is a "hidden feature" that it exists after redirecting. You should handle your tracking based data yourself and set the analytics data on the displaying call/screen. Other solution idea: store the whole analytics instance into your session to live longer than the redirect.

Best regards,

Robert

FOOLanceProd commented 7 years ago

Good morning, Robert.

I thought that was the case. Thanks for the idea to store the instance in a session.

Have a nice day!

-Keith

On Tue, Jan 10, 2017 at 3:01 AM, Robert Kummer notifications@github.com wrote:

Hi Keith,

this is by design. You can not track a campaign or other things through redirects. The event tracking is a "hidden feature" that it exists after redirecting. You should handle your tracking based data yourself and set the analytics data on the displaying call/screen. Other solution idea: store the whole analytics instance into your session to live longer than the redirect.

Best regards,

Robert

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ipunkt/laravel-analytics/issues/37#issuecomment-271547113, or mute the thread https://github.com/notifications/unsubscribe-auth/AXtJCI1hBwZFYy61PBsGBZjFlS-8qGf0ks5rQ2TtgaJpZM4LbM92 .

FOOLanceProd commented 7 years ago

Hi Robert,

Just an update... I ended up storing an array for setting a campaign or an event in a session which is then used on the final landing page using your Analytics::setCampaign() and Analytics::trackEvent() - thanks!

But, one thing I noticed is that subsequent page views aren't categorized under the campaign that's set using Analytics::setCampaign(). I do see in the source code that your function sets parameters that are set prior to initial ga('send', 'xyz') call. (per the docs https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#campaignName). This make sense.

However, subsequent page views don't seem to include campaign tracking. This is also reflected in our Analytics reports. Only the initial page view is categorized under the campaign. It almost seems as though using Analytics javascript model {like ga('set', 'campaignName'); } for custom campaigns doesn't work the same way using the UTM url parameters does. Where UTM url params correctly set a campaign session in analytics, and ga('set', 'campaignName') and the like don't set a session.

Have you seen this to be true as well? If so, how to you get google to create campaign sessions without the url UTM_ parameters?

I hope these questions and my update can help your other users.

Best regards,

Keith

On Tue, Jan 10, 2017 at 3:01 AM, Robert Kummer notifications@github.com wrote:

Hi Keith,

this is by design. You can not track a campaign or other things through redirects. The event tracking is a "hidden feature" that it exists after redirecting. You should handle your tracking based data yourself and set the analytics data on the displaying call/screen. Other solution idea: store the whole analytics instance into your session to live longer than the redirect.

Best regards,

Robert

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ipunkt/laravel-analytics/issues/37#issuecomment-271547113, or mute the thread https://github.com/notifications/unsubscribe-auth/AXtJCI1hBwZFYy61PBsGBZjFlS-8qGf0ks5rQ2TtgaJpZM4LbM92 .