Tagged: cornerstone
-
AuthorPosts
-
June 2, 2016 at 9:55 pm #1023512
hi guys,
A client has requested that I add some tracking pixel scripts to various pages and buttons for their ad agency.Here is one code sample that I added to the Rates page, custom JS:
<!-- Start of DoubleClick Floodlight Tag: Please do not remove Activity name of this tag: Rates~IP1611495 URL of the webpage where the tag is expected to be placed: https://canopytoursnw.com/rates/ This tag must be placed between the <body> and </body> tags, as close as possible to the opening tag. Creation Date: 05/26/2016 --> <script type="text/javascript"> var axel = Math.random() + ""; var a = axel * 10000000000000; document.write('<iframe src="https://5648072.fls.doubleclick.net/activityi;src=5648072;type=ip1610;cat=rates0;dc_lat=;dc_rdid=;tag_for_child_directed_treatment=;ord=' + a + '?" width="1" height="1" frameborder="0" style="display:none"></iframe>'); </script> <noscript> <iframe src="https://5648072.fls.doubleclick.net/activityi;src=5648072;type=ip1610;cat=rates0;dc_lat=;dc_rdid=;tag_for_child_directed_treatment=;ord=1?" width="1" height="1" frameborder="0" style="display:none"></iframe> </noscript> <!-- End of DoubleClick Floodlight Tag: Please do not remove -->
I know it says on the custom JS screen that we don’t need to add any JS tags– but does it hurt if we do?
For the button code, I did this– I gave the button a custom class (book-btn-home) and then added this in the general Customizer>GlobalJS (not the page custom JS):
jQuery('#book-btn-home').click( function(){ <!-- Start of DoubleClick Floodlight Tag: Please do not remove Activity name of this tag: Book Your Tour Now Button~IP1611495 URL of the webpage where the tag is expected to be placed: https://canopytoursnw.com/ This tag must be placed between the <body> and </body> tags, as close as possible to the opening tag. Creation Date: 05/26/2016 --> <script type="text/javascript"> var axel = Math.random() + ""; var a = axel * 10000000000000; document.write('<iframe src="https://5648072.fls.doubleclick.net/activityi;src=5648072;type=ip1610;cat=booky0;dc_lat=;dc_rdid=;tag_for_child_directed_treatment=;ord=' + a + '?" width="1" height="1" frameborder="0" style="display:none"></iframe>'); </script> <noscript> <iframe src="https://5648072.fls.doubleclick.net/activityi;src=5648072;type=ip1610;cat=booky0;dc_lat=;dc_rdid=;tag_for_child_directed_treatment=;ord=1?" width="1" height="1" frameborder="0" style="display:none"></iframe> </noscript> <!-- End of DoubleClick Floodlight Tag: Please do not remove --> });
Should this provide the correct results? If not, is there a better way?
Thanks!
June 3, 2016 at 2:27 am #1023762Hi There,
Thanks for writing in.
Would you mind checking the link below on how to add tracking pixels.
https://community.theme.co/forums/topic/adding-tracking-code/
Let us know how it goes.
Thanks.
June 3, 2016 at 10:44 am #1024384Sorry, that’s not quite what I was looking for.
The scripts need to be added at various pages and various buttons, not site-wide.
Will not the method I applied above work correctly?
And, I just discovered they also want to apply a script to a nav menu button. Advice for that?
thx!
June 3, 2016 at 7:35 pm #1024919Hi There,
Adding that code on Custom JS will not work, because first your code contain a
<noscript>
tag if you put that code on Custom JS that<noscript>
tag will be wrap inside<script>
tag and will cause an error. Second the the comment on your JS code wrote;placed between the <body> and </body> tags
but the Custom JS will output the code inside<head>
and</head>
tag so that does not work.You might want to add the tracking code via child theme’s functions.php file with the code below.
add_action( 'x_before_site_begin', 'x_print_fb_sdk' ); function x_print_fb_sdk(){ if(is_page(41) || is_page(7464) ) : ?> <!-- Start of DoubleClick Floodlight Tag: Please do not remove Activity name of this tag: Rates~IP1611495 URL of the webpage where the tag is expected to be placed: https://canopytoursnw.com/rates/ This tag must be placed between the <body> and </body> tags, as close as possible to the opening tag. Creation Date: 05/26/2016 --> <script type="text/javascript"> var axel = Math.random() + ""; var a = axel * 10000000000000; document.write('<iframe src="https://5648072.fls.doubleclick.net/activityi;src=5648072;type=ip1610;cat=rates0;dc_lat=;dc_rdid=;tag_for_child_directed_treatment=;ord=' + a + '?" width="1" height="1" frameborder="0" style="display:none"></iframe>'); </script> <noscript> <iframe src="https://5648072.fls.doubleclick.net/activityi;src=5648072;type=ip1610;cat=rates0;dc_lat=;dc_rdid=;tag_for_child_directed_treatment=;ord=1?" width="1" height="1" frameborder="0" style="display:none"></iframe> </noscript> <!-- End of DoubleClick Floodlight Tag: Please do not remove --> <?php endif; }
Notice this line
is_page(41) || is_page(7464)
It means this code will only output on page with an ID of 41 or 7464. You can replace that with the actual ID of your pages, the || means OR you can add another set ofis_page()
if you have multiple pages.You can follow this post on How to Locate Post/Page IDs.
And can you clarify the button code? That seems redundant.
Hope it helps, Cheers!
June 3, 2016 at 8:09 pm #1025026Thanks much. Here’s an update.
I installed Google Tag Manager plugin, and modified the functions.php code appropriately as found elsewhere here in the forum.
I then added the page view tags in GTM and tested, and all is good with the page view tracking!
But, now I still have several button events to add in GTM. (The client wants to track specific button clicks on specific pages, not just page views). PLUS, they want to track a nav menu button click.
So now I’m not clear on how to tie a Cornerstone button click or nav menu button to a GTM tag. I realize this may be WAY out of your support scope, so anything you might offer would be appreciated.
Cheers,
BillJune 3, 2016 at 9:16 pm #1025122A final update. Hope this helps anyone else searching for a similar solution to tracking button events in Google Tag Manager.
Once you have your container setup (search this forum for the functions.php mod), make sure you have all the Click variables turned on it GTM.
Then setup a trigger as a click.
GTM couldn’t see my custom class I added to my button, but it _could_ see the button text. Since one of the variables is button text, I just set it to button text = ‘my button text’, then added another statement to make sure the page URL = the desired page. Then add that trigger to your tag in GTM and it’s done!
THis video was very helpful: https://youtu.be/iaJ9HHvKeL8
June 4, 2016 at 3:23 am #1025406Hello There,
Thanks for sharing this information.
This is a very good resource for setting up a Google Click tracking.Best Regards.
-
AuthorPosts