Question about Javascript variable

Question about Javascript variable

Hi, 

I'm new to Javascript so wondering if you can validate that this could work properly. 

On an A/B test page variation, i need to include a link where the href is dynamic replaced, depending on the page visited. I intend to ask the developer to add a javascript variable with the value that I need, then I can use the variable at pageSense test. 

I would ask him do add this line of code: 

  1. <script>
  2. var buttonUrl = "http://www.test.com/a";
  3. </script>

Then, at pageSense JS editor, I would add a code like this: 

  1. document.getElementById("bookNowABTest").href = buttonUrl;

... to replace the #bookNowABTest href value to the buttonUrl variable value. 

Would that work properly? 

Concern: 
* I'm firing the Asynchronous script version over Google Tag Manager. Does that means that there's a chance that the variable buttonUrl is not defined when page sense script is loaded, causing my href to not be replaced properly to the correct value? 

Thanks! 




                            Zoho Desk Resources

                            • Desk Community Learning Series


                            • Digest


                            • Functions


                            • Meetups


                            • Kbase


                            • Resources


                            • Glossary


                            • Desk Marketplace


                            • MVP Corner


                            • Word of the Day



                                Zoho Marketing Automation
                                        • Sticky Posts

                                        • CSS not loading in heat map view

                                          I ran into a problem with two different websites where when I view the heat map experiment, the CSS for the page is not loaded under the heat map overlay. When going to the page directly, everything looks fine. The page also looks right on the Experiments page where a screenshot is used as the thumbnail... The sites are both WordPress websites. I've tried both the regular snippet and async. I'm hoping this has been seen before and there's a solution. Thanks!


                                        Manage your brands on social media



                                                Zoho TeamInbox Resources

                                                  Zoho DataPrep Resources



                                                    Zoho CRM Plus Resources

                                                      Zoho Books Resources


                                                        Zoho Subscriptions Resources

                                                          Zoho Projects Resources


                                                            Zoho Sprints Resources


                                                              Qntrl Resources


                                                                Zoho Creator Resources


                                                                  Zoho WorkDrive Resources



                                                                    Zoho Campaigns Resources

                                                                      Zoho CRM Resources

                                                                      • CRM Community Learning Series

                                                                        CRM Community Learning Series


                                                                      • Tips

                                                                        Tips

                                                                      • Functions

                                                                        Functions

                                                                      • Meetups

                                                                        Meetups

                                                                      • Kbase

                                                                        Kbase

                                                                      • Resources

                                                                        Resources

                                                                      • Digest

                                                                        Digest

                                                                      • CRM Marketplace

                                                                        CRM Marketplace

                                                                      • MVP Corner

                                                                        MVP Corner

                                                                      





                                                                      




                                                                          Design. Discuss. Deliver.

                                                                          Create visually engaging stories with Zoho Show.

                                                                          Get Started Now