Tableau Dashboard- MySQL & AdWords

Now use the power of Tableau to find business insights for AdWords data. With this implement you can forget the days of manually uploading .csv files into Tableau Software to perform data analysis. Now you have to just connect to your database, build dashboard, storyline and many more things.

With the help of Tableau Online tool, you can create dashboard with live connection to your database.  What it means? Its means you have create dashboard only one time and management or your clients can directly view the dashboard on their mobile or tablets to check daily Google AdWords campaigns performance.

Click here to view final outcome :

Follow below steps to implement this code:

If you already have your own MySQL, Microsoft SQL Server, or Oracle database, you can connect to it through Apps Script’s JDBC service. First, you need to ensure that your database accepts connections from any of Apps Script’s IP addresses. These are the address ranges you’ll need to whitelist: - - - - - - - - - -

Note that the JDBC service can only connect to ports 1025 and above. Ensure your database is not serving off a lower port.

For More Information visit:

How to Whitlist above IP CIDR in your Database.

1. Login into your cpanel

2. After successful login into cpanel, scroll down to Databases section.

3. Click on Remote MySQL. as show in the below snapshot


4. Enter all IP Address, which are mentioned above one by one to enable remote connection to your database via Google Apps Scripts.

E.g. To add – IP CIDR as valid host, you can use wildcard. It will save your time and effort.
I will write 64.18.%.%, this will cover all ip address ranging from to



P.S This could be vulnerable to external attacks. Try to avoid usage of wildcard in host entry.

Writing Code Into AdWords Panel:

1.  Open your AdWords Account panel by signing in at Then go to Bulk Operations tab where you need to click Scripts.


2. Then click on +Script  in red color.


This will send AdWord Account data directly to your MySQL database.

Replace the following with actual credentials:
1. ADDRESS: It is the database address/url

//This part of code will fetch data for specified metrics, you can modify the number of metric and type of report. For more infomation you need to check out AWQL on AdWords Developers Guide.
function main() {
var report =
'SELECT Date, CampaignName, Impressions, Clicks, Cost, Conversions, ViewThroughConversions ' +
'WHERE Impressions > 0 ' +
var rows = report.rows();
while (rows.hasNext()) {
var row =;
var campaignDate = row['Date'];
var campaignName = row['CampaignName'];
var impressions = row['Impressions'];
var clicks = row['Clicks'];
var cost = row['Cost'];
var conversions = row['Conversions'];
var viewThroughConversions = row['ViewThroughConversions'];

var dbUrl="jdbc:mysql://ADDRESS:3306/DB_NAME";
var user='DB_USER';
var userPwd='DB_PASSWORD';

// Write rows of data to a table in a single batch.
//function writeManyRecords() {
var conn = Jdbc.getConnection(dbUrl, user, userPwd);
var start = new Date();
var stmt = conn.prepareStatement('INSERT INTO campaignPerformance '
+ '(campaignDate, CampaignName, Impressions, Clicks, Cost, Conversions, ViewThroughConversions) values (?, ?, ?, ?, ?, ?, ?)');
stmt.setString(1, campaignDate);
stmt.setString(2, campaignName);
stmt.setString(3, impressions);
stmt.setString(4, clicks);
stmt.setString(5, cost);
stmt.setString(6, conversions);
stmt.setString(7, viewThroughConversions);

You can also schedule the script to run at specific time.

  1. Click on +Create schedule


2. Small dialogue box will open ,where you schedule the frequency for running your script.



Tableau Dashboard:

  1. Go to new, select MySQL Server then enter you credentials to connect with database.


2. Tableau will show dialogue box with message ‘connecting to data source’


3. Once connected, you will be able to see list of tables available in your database.


4. Good to go…  Here is live demo!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: