• i am using (or attempting to) Google Consumer Surveys and in doing that it said to enter this script
    <script async="" defer="" src="//survey.g.doubleclick.net/async_survey?site=fvcgiyy373qiajuhgbzl3t6idi"></script>

    before closing </head> tag, which I did enter the code snippet under my meta data in header.php yet it is still not working

    I am wondering if I need to use a form of wp_enqueue_script?

    Can someone assist with this?

    Thanks

Viewing 10 replies - 1 through 10 (of 10 total)
  • Yea, you need to use wp_enqueue_script, their instructions would be for a non-wp site. In your functions.php file (or a plugin):

    add_action( 'wp_enqueue_scripts', 'enqueue_survey' );
    function enqueue_survey() {
      wp_register_script('survey','//survey.g.doubleclick.net/async_survey?site=fvcgiyy373qiajuhgbzl3t6idi');
      wp_enqueue_script('survey');
    }
    Thread Starter localmarketingus

    (@localmarketingus)

    it is a WordPress site though.. would that change where i input the code — like in the header.php file?

    No, you should add that code to your functions.php file. When WordPress renders the page, it will add the script tag where it should be.

    Thread Starter localmarketingus

    (@localmarketingus)

    it is still not working.. i added the code you put there in the functions.php file and it still is not showing the survey.

    Then i added just the script in the header.php to see if that was it but it’s not.

    How can i get this thing to work?

    If you view source using my method is the script properly included? Can I take a look at the site?

    Thread Starter localmarketingus

    (@localmarketingus)

    Thread Starter localmarketingus

    (@localmarketingus)

    oops the site is Local Marketing US

    Well, the script is loading correctly, so we got that far. What exactly are you expecting to see? You probably need to initialize it somehow.

    Thread Starter localmarketingus

    (@localmarketingus)

    it is activated and enabled through Google Consumer Surveys ==

    here is an example of what people are supposed to see on the bottom right of the website (the survey)

    Survey Example

    Thread Starter localmarketingus

    (@localmarketingus)

    It works now… ??? i went to the homepage of my site and it wasnt there but when i clicked on another page the survey showed up?? i don’t know why it took that long to show.. it shouldn’t have been that complicated.

    Anyway, thanks for your help

Viewing 10 replies - 1 through 10 (of 10 total)

The topic ‘Adding Script to header.php’ is closed to new replies.