Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1046532

    Hi Enfold-team

    I looked through other threads like https://kriesi.at/support/topic/integrate-java-script-code-into-the-footer-before-the-end-tag/ , your documentation and a lot of info on other sites, but I don’t find a solution.

    As in the thread mentioned above, I’d like to add Amazon tracking code to the footer. I tried adding it to my child theme functions.php.

    But no matter what I insert, it’ll crash the site and give the error “Parse error: syntax error, unexpected ‘}’, expecting end of file in /www/htdocs/w011980a/wp-content/themes/enfold-child/functions.php on line 5” or similar ones.

    I entered this code according to your documentation:

    function add_amazon_associates_code_in_footer(){
    ?>
    <script src=”//z-na.amazon-adsystem.com/widgets/onejs?MarketPlace=US&adInstanceId=6938ec11-aacc-472c-XXXX-XXXXXXXXXXXXX”></script>
    <?php
    }
    add_action(‘wp_footer’, ‘add_amazon_associates_code_in_footer’);

    Alternatively, I could add this asynchrous code which is recommended:

    <div id=”amzn-assoc-ad-6938ec11-aacc-472c-a644-XXXXXXXXX”></div><script async src=”//z-na.amazon-adsystem.com/widgets/onejs?MarketPlace=US&adInstanceId=6938ec11-aacc-472c-a644-XXXXXXXXXXX”></script>

    I’d appreciate your help on this.
    Thank you in advance
    Anja

    #1046701

    Hey Aniona,

    If its a script link as opposed to a script code, you could just put that into the footer.php or header.php file directly.
    Best regards,
    Jordan Shannon

    #1060554

    Hi Jordan

    Thank you. I didn’t feel comfortable writing code into the footer.php (in the main theme, I use a child theme), so I added the code as a footer widget.
    This seems to work fine.

    Thanks and best regards
    Anja

    #1060679

    Hi,

    Glad we could help!

    Please take a moment to review our theme and show your support https://themeforest.net/downloads
    Don’t forget to bookmark Enfold Documentation for future reference.

    Thank you for using Enfold :)

    Best regards,
    Vinay

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Add script code to footer’ is closed to new replies.