Unable to make code snippet perform as expected

Hi Team,

I am trying to add a very simple snippet in one of our pages. I’m using Pro.

The suggested process from the provider is to add a Javascript snippet and a DIV to display the resulting feature:

I added the custom JS in the page, and also added a Content Area snippet to add the suggested HTML code.

I’ll share the details in a separate secure note. If you require further details please let me know.

Thank you in advance for your thoughts.

Best regards,
German

Hi There,

Upon checking your website, I could see that you’ve installed and activated the child theme.

Please add the following code under functions.php file locates in your child theme:

add_action( 'x_before_site_begin', 'print_script_before_site_begin' );
function print_script_before_site_begin(){
	?>	
	<!-- Your Javascript SDK will go here -->
	<?php
}

After that you can add the HTML code to text element:

Let us know how it goes!

Hmmm…

I applied your suggestions, sadly with no success.

  • I added the code and the Javascript SDK in the functions.php (@ child theme)
  • I added the HTML code in the text element; and, just to double-check, in the additional Content Area (@ Men Doubles section).

Would you suggest a different approach? Did I miss anything?

Could it be that the Javascript SDK is not located “ideally right before the closing body tag”?

Please advise.

Thank you for your always excellent support.

German

Hello German,

I have logged in and made necessary changes to the code. I ended up using this:

add_action( 'wp_footer', 'print_script_before_site_begin' );
function print_script_before_site_begin() { ?>  
    <script type="text/javascript">
    (function() {
    var bn = document.createElement('script'); bn.type = 'text/javascript';
    bn.src = ('https:' == document.location.protocol ? 'https://' : '') + 'www.bracketsninja.com/api/bracket/be5c24f44eaae348d33b6957925c89c3?bnurl=' + window.location.href;
    var s = document.getElementsByTagName('head')[0].appendChild(bn);
    })();
    </script> 
<?php }

Please check out the test page. It may take a while to display the contents because it is loaded from a 3rd party site.

Regards.

Yikes,

I thought it was going to be more straightforward within X-Theme.

I tested the snippet out in http://jsfiddle.net/bLpem0j1/1/ and it actually works.

Probably we’re missing something. Would it be a complicated thing to implement with Pro?

Thank you very much for all your help.

Hey @ggavz,

Sorry for the confusion. You don’t need to use functions.php for this. You just need put all that code in a Raw Content element and it should work. I’ve recorded my test. Please see the secure note.

Also, when pasting code in your post, wrap it with backticks like this:

```
code
```

And, it will output like this:

code

Thanks.

Hi Christian,

Thank you very much for your inputs and tips.

Please take a look at “Section 5”, third Row on the “Tournaments” page (this section corresponds to “Men Doubles”).

I added the “Classic Raw Content” as the last element in it; then added the customized ID (as suggested in the video) to that same Row. It seems I’m missing something else. Could it be the SSL certificate?

I’m sure we’re very close to finalize this resolution. What do you think?

Looking forward to hearing your comments.

German

Hey German,

You already have added the HTML with the ID in a Text element. There’s no need to insert the ID in the Column. It’s just an example or show you a possibility. And, I just realized that it would be best to move the Raw Content element with the script in the last section so it’s closer to the closing </body> tag.

Thanks.

Hi Christian,

Thank you for your inputs, and apologies for not indicating the site’s URL.

I followed your suggestions by doing this:

  1. Added a new Section, at the bottom of all the others in that page. In it, I added the Classic Raw Content with the Javascript snippet; hoping to keep this script as close to the tag as I could
  2. In Section 5 (corresponding to “Men Doubles”) I added an empty Content Area element, below all the others in that section, which I Customized with the corresponding Bracket snippet ID

On my side, it doesn’t render; probably because I haven’t completed a missing piece.

Any ideas of what could it be?

German

Hi @ggavz,

I’m not really sure the URL for tournaments page, I couldn’t check the issue as of yet. Would you mind providing the exact URL of the tournament page?

Thanks!

Hi Rad,

This is the URL: https://bayviewvillagetennis.com/tournaments/

Thank you

Hey German,

Your script displays on my end as you can see in my screenshot. Please clear your browser cache and if you’re using browser extensions, please deactivate all of them. Also, try in other browsers and in incognito mode.

Thanks.

Christian, you were right. It was one of my browsers’ extensions.

It works!

Thank you for your great support.

German

You’re welcome.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.