How can I resolve the async.js is blocked” issue?

123    Asked by bharat_9772 in Java , Asked on Jun 7, 2024

 I am an e-commerce website administrator and recently I have received a significant drop in conversion tracking data in my report of Google Ads. When I investigated I found that “www.googleadservices.com/pagead/conversion_async.js “ is being blocked by the Browser. Now how can I troubleshoot and resolve this particular issue? 

Answered by Charles Parr

 In the context of Java programming language, here are the troubleshooting steps Given:-

Verify the scrip blocking source

You should first try to check the browser console for the error that is related to the blocked script. You should look for the message which indicates why the script is being blocked.

Update the contents security policy

If the CSP is the main issue, then you should try to update your particular CSP headers to allow the scrip l.

Checking Ad blockers

You should try to verify if an ad blocker is preventing the script from loading. You can test your site with ad blockers disabled.

Ensure correct script implementation

You should try to ensure that the Google ads conversion is tracking the script correctly and it should be implemented correctly on your website.

Using the debugging tools

You can use tools such as Google Tag Assistant or even Chrome developer tools to debug and verify if the script is properly loaded and implemented.

Contact support

If the issue persists then you should contact Google Ads support for further Instance.

By following these above steps you can easily identify the cause of the blocked script and can take appropriate measures to ensure the conversion tracking data is accurately captured.

Here is the approach given in Java programming language:-

Firstly try to set up a basic java based web server:-

Import com.sun.net.httpserver.HttpServer;
Import com.sun.net.httpserver.HttpHandler;
Import com.sun.net.httpserver.HttpExchange;
Import java.io.IOException;
Import java.io.OutputStream;
Import java.net.InetSocketAddress;
Import java.nio.file.Files;
Import java.nio.file.Paths;
Public class SimpleWebServer {
    Public static void main(String[] args) throws IOException {
        HttpServer server = HttpServer.create(new InetSocketAddress(8080), 0);
        Server.createContext(“/”, new RootHandler());
        Server.setExecutor(null);
        Server.start();
        System.out.println(“Server started on port 8080”);
    }
    Static class RootHandler implements HttpHandler {
        @Override
        Public void handle(HttpExchange exchange) throws IOException {
            String response = new String(Files.readAllBytes(Paths.get(“index.html”)));
            Exchange.sendResponseHeaders(200, response.length());
            OutputStream os = exchange.getResponseBody();
            Os.write(response.getBytes());
            Os.close();
        }
    }
}

Now you should try to create an HTML page with the Google ads conversion script:-


        [removed] = function() {
            Gtag(‘event’, ‘conversion’, {
                ‘send_to’: ‘AW-CONVERSION_ID’,
                ‘value’: 1.0,
                ‘currency’: ‘USD’
            });
            // Check if the script is loaded
            Const script = document.querySelector(‘script[src=https://www.googleadservices.com/pagead/conversion_async.js]’);
            If (script) {
                Console.log(‘Google Ads conversion script is loaded.’);
            } else {
                Console.error(‘Google Ads conversion script is not loaded.’);
            }
        };


Now you can run the web server and access the Web Page:-

Javac SimpleWebServer.java

Java SimpleWebServer



Your Answer

Interviews

Parent Categories