Tagged: onclick event
-
AuthorPosts
-
October 1, 2018 at 6:23 pm #1016705
hey folks,
today i need a little bit of help. We made a short and clean landingpage (see private content) for a customer and he wants to track downloads from that page with a google conversion and tracking codes from the online marketers. But we can’t get the onclick event running.1. onclick event
So this is what we have:
This google analytics tracking code at the right place in theme options<!-- Global site tag (gtag.js) - Google Analytics --> <script async src="https://www.googletagmanager.com/gtag/js?id=UA-xxxxxxxx-x"></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'UA-xxxxxxxx-x', { 'anonymize_ip': true }); </script>
Then we have a Button on the landingpage – and following your instructions – with the class: vip
And i searched the forum and found this script and placed it at the end of the functions.php from the child-theme:function ava_custom_script() { ?> <script type="text/javascript"> (function($) { // vip button onclick attribute $('.vip a').attr('onclick', 'gtag(\'event\', \'click\', {\'event_category\' : \'download\', \'event_label\' : \'vip\', \'non_interaction\': true})'); })(jQuery); </script> <?php } add_action('wp_footer', 'ava_custom_script');
We also made the conversion target in analytics with category:download, action:click, label:vip, value:1
but google counts no event!?2. integrating the other script in the onclick event
In the first step i placed the other codes from the marketers in a code block on the landing page with success, but now they want to have the other codes also with the onclick event – is it possible to combine this in the script?Here is the code from the code block element to integrate in onclick event
<script async="true"> (function(id) { var i = new Image(); i.src = '//k.intellitxt.com/log/pxl/' + id + '/' + encodeURIComponent(window.top.location.href)+ '?' + (+new Date); })(575); </script> <div style="display:inline;"> <img src="https://farm-de.plista.com/activity2;domainid:1027692;campaignid:1058582;event:31"style="width:1px;height:1px;" alt="" /> <img src="https://farm-de.plista.com/activity2;domainid:1027692;campaignid:1058580;event:31"style="width:1px;height:1px;" alt="" /> <img src=" https://tracking.lqm.io/conversion_event/campaign/67556/t.gif?conversion_id=1&value=[0.0]" width="1" height="1" /> <img src=" https://tracking.lqm.io/conversion_event/campaign/67562/t.gif?conversion_id=1&value=[0.0]" width="1" height="1" /> </div>
So have i picked the right script for this?
Any help is much appreciated.Thanks
heavyOctober 2, 2018 at 7:41 am #1016918Hey heavyman,
Thank you for using Enfold.
Have you tried adding the tracking function on an onClick attribute? This doc might help.
// https://developers.google.com/analytics/devguides/collection/gtagjs/events
Did you set up or create a goal?
// https://support.google.com/analytics/answer/1032415?hl=en
Best regards,
IsmaelOctober 2, 2018 at 8:13 am #1016927Hey Ismael,
thanks for your reply. Yes, as you can see in the script I posted above I tried to integrate the onclick event and we set up a goal in google as descibed in my post.
Best regards
heavyOctober 3, 2018 at 2:13 am #1017285Hi,
Can you please provide a screenshot of the goal settings? In the “Trigger” configuration, try to set the trigger type to “Click” and the “This trigger fires on” settings to “Some clicks”. You’ll see a few select fields, set it to “Class” -> “matches css selector” and then add the class attribute of your button on the last field.
Best regards,
IsmaelOctober 3, 2018 at 11:25 am #1017462Hi Ismael,
I think you are referring to the google tag manager?!
But we are not using it – we are using the “normal” analytics with a conversion created (see screenshot ).
The only thing we changed this time is the oncklick event – that the conversion should count on button click.Best regards
heavyOctober 3, 2018 at 11:26 am #1017464October 4, 2018 at 3:05 pm #1017927Hi,
Yes, I was referring to the gtag manager because you’re using the gtag manager snippet instead of the google analytics library. If you want to implement the google analytics library, please refer to the following docs.
// https://developers.google.com/analytics/devguides/collection/analyticsjs/
// https://developers.google.com/analytics/devguides/collection/analyticsjs/eventsYou should use the “ga” function instead of “gtag” tracker.
Best regards,
IsmaelOctober 4, 2018 at 3:15 pm #1017936Hi Ismael,
since we are using the global site tag (gtag.js) code for analytics I think we have to use the gtag as you can see here.
https://developers.google.com/analytics/devguides/collection/gtagjs/#tracking-snippet
https://developers.google.com/analytics/devguides/collection/gtagjs/events
Anyway – at this moment we are working on a combined solution which we try to implement in a few minutes and see if it is working.
I’ll keep you informed.Best regards
heavy- This reply was modified 6 years, 1 month ago by heavyman.
October 4, 2018 at 5:00 pm #1017969Hi Ismael,
the “dirty” version is working now – not as expected as a conversion but as an event shown in analytics – this is enough for now. We implemented the tracking codes too and think that they are working;-)
Thank you for your help and I think you can close this special one now!
Best regards
heavyOctober 4, 2018 at 8:39 pm #1018001 -
AuthorPosts
- You must be logged in to reply to this topic.