How to get ad slot by slot name - google-dfp

I'm using DFP to show ads on a web page.
Is there any way to refer to particular ad slot by name? e.g. googletag.getSlotByName('abc')
My intension is to refresh ads in particular slots.

Yes. The pubads.defineSlot method returns a reference to the slot. This reference can be saved in a variable so you can use it later to refresh it. This would be an example:
googletag.cmd.push(function() {
var slotABC = googletag.defineSlot("/12345678/SLotABC", [728, 90],
"div-gpt-ad-1327312723268-0").addService(googletag.pubads());
googletag.enableServices();
googletag.display("div-gpt-ad-1327312723268-0");
//Then you can refer to it and refresh it like this:
googletag.pubads().refresh([slotABC]);
})
More info: here

Related

How to retrieve the rows which are selected in the list report page of smart templates

This is the List Report type of Smart Template application
Here I have selected 2nd and 5th row, I also have a button named Send Requests in the section part which is highlighted. If I click this button it calls a javascript controller function which is defined in the extensions of the application. In this js function how can I retrieve the selected rows that are selected?
I have enabled the checkboxes in this page by mentioning this code
"settings": { "gridTable": false, "multiSelect": true } in the manifest.json
As it was recommended by this link https://sapui5.netweaver.ondemand.com/#docs/guide/116b5d82e8c545e2a56e1b51b8b0a9bd.html
I want to know how can I retrieve the rows which got selected?
There is an API that you can use for your use case. It is described here: https://sapui5.netweaver.ondemand.com/#docs/guide/bd2994b69ef542998becbc69ab093f7e.html
Basically, you just need to call the getSelectedContexts method. Unfortunately you will not be able to really get the items themselves, only the binding contexts (which point to the data entities which are selected). Excerpt from the documentation:
After you have defined a view extension, you can access and modify the
properties of all UI elements defined within these extensions (for
example, change the visibility). However, you cannot access any UI
elements that are not defined within your view extensions.
In this type of table there is way.
var myTable=sap.ui.getCore().byId("your table id");
get all rows:
var myTableRows=myTable.getRows();
now get selected Indices
var selectedIndeices=myTable.getSelectedIndices(); //this will give you array of indeices.
now run loop on indeices array. And get particular row item;
// get binding path
var bindingpath=myTableRows[2].getBindingContext().sPath; // this will return eg:"/ProductCollection/2"
// now get Binding object of that particular row.
var myData=myTableRows[2].getModel().getObject(bindingpath); // this will return binding object at that perticular row.
// once your loop is over in the end you will have all object of selected row. then do whatever you want to do.
If you use smart template create an extension.
This is the standard event befor the table is rebinding:
onBeforeRebindTableExtension: function (oEvent) {
this._table = oEvent.getSource().getTable();
}
In your action function (or where you want) call the table and get the context :
this._table.getSelectedContexts();

Regarding Facebook fbq('track', 'Lead'); - is there a way to track different kind of leads?

in example -
I have a webpage with 2 buttons -
1. Call
2. SMS
I want to separate Leads for that (let's call it Lead_call and Lead_sms), since I want to run campaigns that focus optimisation per action (1 for Lead_call and 1 for Lead_sms).
Thanks.
That's possible by specifying additional variables for each lead.
Check this help article: https://developers.facebook.com/docs/facebook-pixel/events-advanced-use-cases/v2.9
<!-- Facebook Event Code -->
<script>
fbq('track', 'Lead', {
content_name: 'booking',
content_category: 'voucher',
value: 1.00,
currency: 'EUR'
});
</script>
In this example the event Lead is specified with content_name and content_category. These additional variables are later accessible to distinguish between different Lead types.

Setting value in variable provided while creating paypal buy button

I have this paypal buttom generated to buy.The scripts contains some variable whose values are already provided but i want to provide the value to variables dynamically.
This is the buy button generated.
<script
data-callback="http://sajilobazar.com"
data-tax="3"
data-shipping="1"
data-currency="USD"
data-amount="45"
data-quantity="1"
data-name="helo"
data-button="buynow" src="https://www.paypalobjects.com/js/external/paypal-button.min.js?merchant=*****#yahoo.com" async="async">
</script>
As seen in the above code the variables like data-tax are pre populated.I want to provide my own value.
This is what i tried
var x= "3";
data-tax=x
But it won't work.Please help!!!
You can use data-tax-editable which makes tax editable and enter a value to pass the dynamic tax variable.
Eg:
<script
data-callback="http://sajilobazar.com"
data-tax-editable="3"
data-shipping="1"
data-currency="USD"
data-amount="45"
data-quantity="1"
data-name="helo"
data-button="buynow" src="https://www.paypalobjects.com/js/external/paypal-button.min.js?merchant=*****#yahoo.com" async="async">
</script>
But, alternatively you to use Button manager API to create dynamic buttons via BMCreateButton API call.

How do I get the information about the selected node in the Google Charts Org Chart widget?

I have a chart rendered via the Google Charts Org Chart API. How do I get the data about the selected node when a user clicks on a node. I understand it to the point where I make the "getSelection" call to output selection information to the Javascript console:
console.log(chart.getSelection());
When I look in the Chrome Javascript console, I can see the object (see below), but it doesn't show any attributes of the node in the chart. It only shows row and column. Is there another call to get the actual attributes of the node (like the name, etc)?
You should call chart.getSelection(), not this., because in your function this refers to window, and thus you call window.getSelection() that returns an unrelated object.
Here is the complete example how to get chart selection:
Google Charts. Interacting With the Chart
The correct code from the link above, where chart and data refer to global variables:
var selectedItem = chart.getSelection()[0];
if (selectedItem) {
var selectedValue = data.getValue(selectedItem.row, 0);
console.log('The user selected ' + selectedValue);
}
This works for me.
chart is the instance of your chart and data is the container of your data (a google DataTable instance), composed in the page or fetched via ajax.
Once you get the current selection object with chart.getSelection() you are able to query your dataset with the current row position data.getValue(row, col), to obtain the corresponding record.
showCurrentDetailCard() is a custom function that i use to display the details of the current node.
google.visualization.events.addListener(chart, 'select', selectHandler);
function selectHandler() {
var selection = chart.getSelection();
if (selection.length > 0) {
var c = selection[0];
showCurrentDetailCard(data.getValue(c.row, 0));
}
}
Hope this helps.

Sencha touch charts 2: Dynamically create chart and load series from the store?

I want to create a scatter chart dynamically and load the series by fetching the data from the store. Is there any method to do that? I did the following:
var myChart = Ext.create('Ext.chart.Chart',{
id:'myChart',
renderTo:'myPanel',
axes:[], // blank because i need to add axes from store
series:[] // blank because i need to add series from store
:
:
});
for(conditions){
myChart.config.axes[0].fields.push(record[cnt].data.fieldName);
var series = {
type:'scatter',
axis:['right', 'bottom'],
xField:'myXfield',
yField:record[cnt].data.yfieldVal
}
myChart.config.series.push(series);
}//for loop ends
myChart.redraw();
Iam not able to see the chart with the plots that are dynamically added.
Any help will be appriciated!
Thanks!
I realized how to address the issue. I declared Global variables for the store name and other related fields. I created the get and set methods. These are defined in app.js file. I was able to set the values dynamically to these global variables using set methods and use the assigned values using the get methods. I hope someone will be able to use this technique if required.