Google Tag Manager Conversion value mismatch - google-analytics

Google Tag Assistant showing an error:
"Conversion value mismatch between and tag."
Please review below code snippets.
/* <![CDATA[ */
var google_conversion_id = <conversion_id>;
var google_conversion_language = "en";
var google_conversion_format = "3";
var google_conversion_color = "ffffff";
var google_conversion_label = "<conversion_label>";
if (813.00) {
var google_conversion_value = "813.00";
var google_conversion_currency = "AED";
}
var google_remarketing_only = false;
/* ]]> */
<noscript>
<div style="display:inline;">
<img height="1" width="1" style="border-style:none;" alt="" src=""//www.googleadservices.com/pagead/conversion/<conversion_id>/?value=813.00&currency_code=AED&label=<conversion_label>&guid=ON&script=0""/>
</div>
</noscript>

Related

GMap V3 valid JSON from PHP as replacement for GDownloadUrl [duplicate]

I will really appreciate help for this.
My html v2 file with some temporary key works fine. I am getting locations from some XML, create different colors markers and add some URLs also from XML attributes in Info Window(not too much complicated). Now I need to migrate this to v3. I found some equivalents for functions from v2 but I didn't find for GDownloadUrl( for loading XML) and also GIcon(G_DEFAULT_ICON); Can someone please look at both of my codes and tell me how to change to make this works also in v3. I changed most of the things so if someone can see some error I will be thankful. Thanks in advance.
Version 2:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Google Maps</title>
<script src="http://maps.google.com/maps?file=api&v=2&sensor=false&key=AIzaSyA4UDNP6MZ" type="text/javascript"></script>
</head>
<body onunload="GUenter code herenload()">
<!-- you can use tables or divs for the overall layout -->
<table border=1>
<tr>
<td>
<div id="map" style="width: 1250px; height: 1250px"></div>
</td>
</tr>
</table>
<script type="text/javascript">
//<![CDATA[
if (GBrowserIsCompatible()) {
var gmarkers = [];
// A function to create the marker and set up the event window
function createMarker(point,name,alarm,markerOptions) {
var marker = new GMarker(point,markerOptions);
GEvent.addListener(marker, "click", function() {
var alarmanchor1='<span class="url"><a href="' + alarm;
var alarmanchor2='" title="www" target="_blank">Event List</a></span>';
var alarmanchor=alarmanchor1+alarmanchor2;
marker.openInfoWindowHtml(alarmanchor);
});
return marker;
}
// This function picks up the click and opens the corresponding info window
function myclick(i) {
GEvent.trigger(gmarkers[i], "click");
}
// create the map
var map = new GMap2(document.getElementById("map"));
map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());
map.setCenter(new GLatLng( 41.932797,21.483765), 10);
// Read the data from alarms33.xml
GDownloadUrl("alarms33.xml", function(doc) {
var xmlDoc = GXml.parse(doc);
var markers = xmlDoc.documentElement.getElementsByTagName("marker");
for (var i = 0; i < markers.length; i++) {
// obtain the attribues of each marker
var lat = parseFloat(markers[i].getAttribute("lat"));
var lng = parseFloat(markers[i].getAttribute("lng"));
var point = new GLatLng(lat,lng);
var alarm = markers[i].getAttribute("alarm");
var label = markers[i].getAttribute("label");
var severity = parseFloat(markers[i].getAttribute("severity"));
var severityIcon = new GIcon(G_DEFAULT_ICON);
var color;
if (severity == 0) color = "66FF33";
else if (severity == 1) color = "990099";
else if (severity == 2) color = "00CCFF";
else if (severity == 3) color = "FFFF00";
else if (severity == 4) color = "FFCC00";
else if (severity == 5) color = "FF3300";
else color = "yellow";
severityIcon.image = "http://www.googlemapsmarkers.com/v1/" + color;
severityIcon.iconSize = new GSize(15, 30);
markerOptions = { icon:severityIcon };
// create the marker
var marker = createMarker(point,label,alarm,markerOptions);
map.addOverlay(marker);
}
});
}
else {
alert("Sorry, the Google Maps API is not compatible with this browser");
}
//]]>
</script>
</body>
</html>
Version 3:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Google Maps</title>
<script src="http://maps.google.com/maps?file=api&v=3&sensor=false&key=AIzaSyDsa1LyWOQ" type="text/javascript"></script>
</head>
<body onunload="initialize()">
<!-- you can use tables or divs for the overall layout -->
<table border=1>
<tr>
<td>
<div id="map" style="width: 1250px; height: 1250px"></div>
</td>
</tr>
</table>
<script type="text/javascript">
//<![CDATA[
var gmarkers = [];
// A function to create the marker and set up the event window
function createMarker(point,name,alarm,markerOptions) {
var marker = new google.maps.Marker(point,markerOptions);
google.maps.event.addListener(marker, "click", function() {
var alarmanchor1='<span class="url"><a href="' + alarm;
var alarmanchor2='" title="www.skolaznanja.com" target="_blank">Event List</a></span>';
var alarmanchor=alarmanchor1+alarmanchor2;
var infoWindow=new google.maps.InfoWindow();
infoWindow.setContent(alarmanchor);
infowindow.open(map,marker);
});
return marker;
}
// This function picks up the click and opens the corresponding info window
function myclick(i) {
google.maps.event.trigger(gmarkers[i], "click");
}
// create the map
function initialize() {
var mapDiv = document.getElementById("map");
var map;
var myLatlng = new google.maps.LatLng(41.932797,21.483765);
var myOptions = {
zoom:10,
center:myLatlng,
mapTypeId:google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(mapDiv, myOptions);
}
//var map = new google.maps.Map(document.getElementById("map"));
//map.addControl(new GLargeMapControl());
//map.addControl(new GMapTypeControl());
//map.setCenter(new google.maps.LatLng( 41.932797,21.483765), 10);
// Read the data from example.xml
GDownloadUrl("alarms44.xml", function(doc) {
var xmlDoc = GXml.parse(doc);
var markers = xmlDoc.documentElement.getElementsByTagName("marker");
for (var i = 0; i < markers.length; i++) {
// obtain the attribues of each marker
var lat = parseFloat(markers[i].getAttribute("lat"));
var lng = parseFloat(markers[i].getAttribute("lng"));
var point = new google.maps.LatLng(lat,lng);
var alarm = markers[i].getAttribute("alarm");
var label = markers[i].getAttribute("label");
var severity = parseFloat(markers[i].getAttribute("severity"));
var severityIcon = new GIcon(G_DEFAULT_ICON);
var color;
if (severity == 0) color = "66FF33";
else if (severity == 1) color = "990099";
else if (severity == 2) color = "00CCFF";
else if (severity == 3) color = "FFFF00";
else if (severity == 4) color = "FFCC00";
else if (severity == 5) color = "FF3300";
else color = "yellow";
severityIcon.image = "http://www.googlemapsmarkers.com/v1/" + color;
severityIcon.iconSize = new GSize(15, 30);
markerOptions = { icon:severityIcon };
// create the marker
var marker = createMarker(point,label,alarm,markerOptions);
map.setMap(marker);
}
});
//]]>
</script>
</body>
</html>
As you've noted GDownloadUrl() no longer exists in GMap V3. I'd recommend jQuery.get(url)
I posted an example How to parse xml file for marker locations and plot on map.
UPDATE: As #user1191860 points out below there is a utility for GMap V3 xmlparsing. I was not aware of it. AFAIK, no reason not to use it.
You need to add
<script src="http://gmaps-samples-v3.googlecode.com/svn-history/r28/trunk/xmlparsing/util.js"></script>
to your html page.
Interesting that the author also includes a jQuery example

newbie: flex netstream how to get my code stream and receive netstreams correctly?

I have problems getting my flex code to work, below is my code I try to netstream a webcam and receive it and use 2 functions for that. Any flex guru can help me fix these functions?
function onNetConnectionPublish():void {
StatusMessage("onNetConnectionPublish called");
ncNetStream = new NetStream(nc, NetStream.DIRECT_CONNECTIONS);
ncNetStream.addEventListener(NetStatusEvent.NET_STATUS, sendNetStreamHandler);
ncNetStream.publish("media");
ncNetStream.attachAudio(Microphone.getMicrophone());
ncNetStream.attachCamera(Camera.getCamera());
}
and:
function connectToRemote(remoteId:String) {
StatusMessage("connectToRemote(" + remoteId + ")");
ncNetStream = new NetStream(nc, remoteId);
ncNetStream.addEventListener(NetStatusEvent.NET_STATUS, receiveNetStreamHandler);
ncNetStream.play("media");
}
display video:
The Publisher Application:
private function Publisher():void{
var camera1:Camera = Camera.getCamera();
var video:Video = new Video(285, 254);
if (camera1)
{
video.attachCamera(camera1);
VideoDisplay1.addChild(video);
camera1.addEventListener(ActivityEvent.ACTIVITY, camera_activity);
camera1.addEventListener(StatusEvent.STATUS, camera_status);
}
var nc:NetConnection = new NetConnection();
nc.connect("rtmp://your/stream/url");
nc.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
function netStatusHandler(event:NetStatusEvent):void {
switch (event.info.code) {
case "NetConnection.Connect.Success":
var ns:NetStream = new NetStream(nc,NetStream.CONNECT_TO_FMS);
ns.attachCamera(camera1);
ns.publish("videofeed", "live");
break;
case "NetStream.Play.StreamNotFound":
trace("Unable to locate video: ");
break;
}
}
}
The Reciever Application :
import mx.utils.ObjectUtil;
private var nc:NetConnection;
private var ns:NetStream;
private var video:Video;
private var meta:Object;
private function init():void {
var nsClient:Object = {};
nsClient.onMetaData = ns_onMetaData;
nsClient.onCuePoint = ns_onCuePoint;
nc = new NetConnection();
nc.connect(null);
ns = new NetStream(nc);
ns.play("http://www.helpexamples.com/flash/video/cuepoints.flv");
ns.client = nsClient;
video = new Video();
video.attachNetStream(ns);
uic.addChild(video);
}
private function ns_onMetaData(item:Object):void {
trace("meta");
meta = item;
// Resize Video object to same size as meta data.
video.width = item.width;
video.height = item.height;
// Resize UIComponent to same size as Video object.
uic.width = video.width;
uic.height = video.height;
panel.title = "framerate: " + item.framerate;
panel.visible = true;
trace(ObjectUtil.toString(item));
}
private function ns_onCuePoint(item:Object):void {
trace("cue");
}
Reciever mxml code :
<mx:Panel id="panel" visible="false">
<mx:UIComponent id="uic" />
<mx:ControlBar>
<mx:Button label="Play/Pause" click="ns.togglePause();" />
<mx:Button label="Rewind" click="ns.seek(0); ns.pause();" />
</mx:ControlBar>
</mx:Panel>

Flex Android application suspends when using jpeg image

I have a flex application in which I have to convert a jpeg picture taken by camera using base64 converter and then upload the result to sqlite database (as MEDIUMBLOB). The code looks like this:
MXML declarations of images:
<s:Group width="480" height="304">
<s:Label x="0" y="0" width="100%" height="34" backgroundColor="#4D4D4D"
color="#FFFFFF" fontSize="30" text=" Select photo" verticalAlign="middle"/>
<s:Image id="image" x="10" y="42" width="217" height="246" />
<s:Image id="image2" x="10" y="42" width="217" height="246" source = "#Embed(source='skins/PhotoNotAvailable.jpg')"/>
<s:Button x="235" y="42" width="235" height="84" label="Take a Picture"
click="captureImage(event)" enabled="{CameraUI.isSupported}" fontSize="30"/>
<s:Button x="235" y="150" width="235" height="70" label="Delete"
click="deletePhoto(event)" fontSize="30"/>
</s:Group>
Scripts for taking a picture and convertion:
//Taking the pictures
protected function application1_applicationCompleteHandler(event:FlexEvent):void {
image.setVisible(true);
image2.setVisible(false);
if (CameraUI.isSupported){
var mediaPromise:MediaPromise;
camera = new CameraUI();
camera.addEventListener(MediaEvent.COMPLETE, onComplete);
camera.addEventListener(ErrorEvent.ERROR, onError);
} else {
}
}
protected function view1_activateHandler(event:Event):void
{
conn = data as SQLConnection;
}
private function captureImage(event:MouseEvent):void {
camera.launch(MediaType.IMAGE);
}
private function onError(event:ErrorEvent):void {
trace("error has occurred");
}
private function onComplete(event:MediaEvent):void {
var mediaPromise:MediaPromise = event.data;
image.source = mediaPromise.file.url;
pictureTaken = true;
}
//Convertion and uploading to database
protected function AddHandler(event:MouseEvent):void
//irrelevant code skipped
insertStmt = new SQLStatement();
insertStmt.sqlConnection = conn;
var insertSQL:String = ("INSERT INTO RecipeDB (RecipeID, Name, Category, Origin, Recipe, Favorite, Image)" + "VALUES (:RecipeID, :Name, :Category, :Origin, :Recipe, :Favorite, :Image)");
insertStmt.text = insertSQL;
if(pictureTaken)
{
var jencoder:JPEGEncoder = new JPEGEncoder(75);
var imageByteArray:ByteArray = jencoder.encode(image.bitmapData);
var baseEncoder:Base64Encoder = new Base64Encoder();
baseEncoder.encodeBytes(imageByteArray);
encodedBytes = baseEncoder.toString();
}
else
{
var jencoder:JPEGEncoder = new JPEGEncoder(75);
var imageByteArray:ByteArray = jencoder.encode(image2.bitmapData);
var baseEncoder:Base64Encoder = new Base64Encoder();
baseEncoder.encodeBytes(imageByteArray);
encodedBytes = baseEncoder.toString();
}
insertStmt.parameters[":RecipeID"] = ID as int;
insertStmt.parameters[":Name"] = NameArea.text;
insertStmt.parameters[":Category"] = TypeArea.text;
insertStmt.parameters[":Origin"] = OriginArea.text;
insertStmt.parameters[":Recipe"] = RecipeArea.text;
insertStmt.parameters[":Favorite"] = 0 as int;
insertStmt.parameters[":Image"] = encodedBytes;
insertStmt.execute();
}
//Deleting photo
protected function deletePhoto(event:MouseEvent):void
{
pictureTaken = false;
image.setVisible(false);
image2.setVisible(true);
}
Now, if no picture was taken, the program uploads skins/PhotoNotAvailable.jpg to the DB correctly, but if the picture was taken or taken and deleted, the program hangs (android asks if to close it or wait). I have checked the size of taken pictures and it does not exceed MEDIUMBLOB`s size (picture has ca. 2 MBytes). What could be wrong?
My first thought from your description of what happens is "a breakpoint." The only time my phone gives me that message is when I'm debugging and it's stopped on a break point for too long.
You might cast your event.data as MediaPromise
private function onComplete(event:MediaEvent):void {
var mediaPromise:MediaPromise = event.data as MediaPromise;
image.source = mediaPromise.file.url;
pictureTaken = true;
}
Though that may just be a copying error.
So far as I can tell you don't need to base64 encode the image data. It's already encoded and ready to be inserted into a database. Perhaps "double-encoding" is somehow creating a problem. ???
I would change
if(pictureTaken)
{
var jencoder:JPEGEncoder = new JPEGEncoder(75);
var imageByteArray:ByteArray = jencoder.encode(image.bitmapData);
var baseEncoder:Base64Encoder = new Base64Encoder();
baseEncoder.encodeBytes(imageByteArray);
encodedBytes = baseEncoder.toString();
}
else
{
var jencoder:JPEGEncoder = new JPEGEncoder(75);
var imageByteArray:ByteArray = jencoder.encode(image2.bitmapData);
var baseEncoder:Base64Encoder = new Base64Encoder();
baseEncoder.encodeBytes(imageByteArray);
encodedBytes = baseEncoder.toString();
}
insertStmt.parameters[":RecipeID"] = ID as int;
insertStmt.parameters[":Name"] = NameArea.text;
insertStmt.parameters[":Category"] = TypeArea.text;
insertStmt.parameters[":Origin"] = OriginArea.text;
insertStmt.parameters[":Recipe"] = RecipeArea.text;
insertStmt.parameters[":Favorite"] = 0 as int;
insertStmt.parameters[":Image"] = encodedBytes;
insertStmt.execute();
to
var jencoder:JPEGEncoder = new JPEGEncoder(75);
var imageByteArray:ByteArray;
if(pictureTaken)
{
imageByteArray = jencoder.encode(image.bitmapData);
}
else
{
imageByteArray = jencoder.encode(image2.bitmapData);
}
insertStmt.parameters[":RecipeID"] = ID as int;
insertStmt.parameters[":Name"] = NameArea.text;
insertStmt.parameters[":Category"] = TypeArea.text;
insertStmt.parameters[":Origin"] = OriginArea.text;
insertStmt.parameters[":Recipe"] = RecipeArea.text;
insertStmt.parameters[":Favorite"] = 0 as int;
insertStmt.parameters[":Image"] = imageByteArray;
insertStmt.execute();
If for some reason you still want the base64 encoding and it's not creating the problem, I would still suggest refactoring the code like this to save duplication since the only thing that varies between the two if branches is the source of the bitmap data.
var jencoder:JPEGEncoder = new JPEGEncoder(75);
var imageByteArray:ByteArray;
if(pictureTaken)
{
imageByteArray = jencoder.encode(image.bitmapData);
}
else
{
imageByteArray = jencoder.encode(image2.bitmapData);
}
var baseEncoder:Base64Encoder = new Base64Encoder();
baseEncoder.encodeBytes(imageByteArray);
encodedBytes = baseEncoder.toString();
However, this is just a first stab at it. It would be useful to see the code all together. I'm assuming that encodedBytes is a String available to the whole class? I can't see how/when AddHandler is invoked, so I also can't tell variable states when it is called (which could be related to the problem). It would also be useful to know what's happening after the AddHandler is completed. Perhaps it's an error occurring after the insert statement that is hanging up?
Did you debug it and get any errors to share?
I know the post is a month old, so maybe you already figured it out. Maybe you could share it so others don't make the same mistake. Either way, I hope this can help someone.

Finding previous word boundary with enter key?

This code works great and it get the last word, but when I use enter key
it behaves erroneously and stops getting last word(s). When I comment the findPreviousWordBoundary line, it gets all text:
<fx:Script>
<![CDATA[
import flashx.textLayout.elements.ParagraphElement;
protected function togglebutton1_clickHandler(event:MouseEvent):void {
var urlLoader:URLLoader = new URLLoader();
var suggestions:Array = new Array();
var suggested:Array = new Array();
var textfields:Array = new Array();
var format:TextFormat = new TextFormat();
var currentSelection:int = -1;
mytextflow.addEventListener(KeyboardEvent.KEY_UP, suggest);
function suggest(event:KeyboardEvent):void {
suggested = [];
var activePos:int = mytextflow.selectionActivePosition
var curParagraph:ParagraphElement =
mytextflow.textFlow.findLeaf(activePos).getParagraph();
var wordBoundary:int = curParagraph.
findPreviousWordBoundary(activePos);
//var lastword:String = curParagraph.getText(wordBoundary,activePos);
}
}
]]>
</fx:Script>
<s:ToggleButton x="21" y="10"
click="togglebutton1_clickHandler(event)"/>
<s:RichEditableText
id="mytextflow"
x="111"
y="43"
width="363"
height="285"
backgroundColor="#C39191"/>
</s:Application>

spark Text area height adjust to content

i want to adjust the size of my text area in action script based on the text i put inside dynamically, but absolutly don't know how to do that... searched a lot for nothing. Here is my code if it can help you situate the problem. I want to adjust the height of msgLabel to the content.
Thanks a lot ;).
public function createTweet(tweet:XML, lineName:String, isTweetInList:Boolean):IVisualElement{
var authorS:String = tweet.posterName;
var tweetID:String = tweet.tweetID;
//Main vertical group
var vg:VGroup = new VGroup();
vg.percentWidth = 100;
if(!isTweetInList){
//Add the new VGroup to the tweetTabHolder
tweetTabHolder[tweetID+lineName] = vg;
//Add the new tweetID to the tweet posted by an author
if(tweetByLineByAuthor[authorS] == null)
tweetByLineByAuthor[authorS] = new Dictionary();
if(tweetByLineByAuthor[authorS][lineName] == null)
tweetByLineByAuthor[authorS][lineName] = new ArrayList();
tweetByLineByAuthor[authorS][lineName].addItem(tweetID);
}
vg.setStyle("backgroundAlpha", 0);
vg.paddingLeft = 20;
var sp0:Spacer = new Spacer();
sp0.height = 10;
vg.addElement(sp0);
//Tweet Content
//Author
var hgA:HGroup = new HGroup();
var aSpacer:Spacer = new Spacer();
aSpacer.width = 10;
hgA.addElement(aSpacer);
var authorLabel:RichText = new RichText();
authorLabel.text = authorS;
authorLabel.setStyle("fontSize",20);
authorLabel.setStyle("fontWeight",FontWeight.BOLD);
authorLabel.setStyle("color",authorColor);
authorLabel.addEventListener("click",authorClickHandler);
authorLabel.addEventListener(MouseEvent.MOUSE_OVER,authorFocusInHandler);
authorLabel.addEventListener(MouseEvent.MOUSE_OUT,authorFocusOutHandler);
hgA.addElement(authorLabel);
if(tweet.posterName == userNameLogged || isTweetInList){
var abs1:Spacer = new Spacer();
abs1.width = 25;
hgA.addElement(abs1);
hgA.addElement(createDeleteTweetButton(tweetID,vg, isTweetInList));
var abs2:Spacer = new Spacer();
}
if(!isTweetInList){
abs2.width = 4;
hgA.addElement(abs2);
hgA.addElement(createFavorisButton(tweetID));
}
vg.addElement(hgA);
//Msg
var hgM:HGroup = new HGroup();
var mSpacer:Spacer = new Spacer();
mSpacer.width = 15;
hgM.addElement(mSpacer);
var msgLabel:TextArea = new TextArea();
hgM.addElement(msgLabel);
hgM.percentWidth = 100;
msgLabel.percentWidth = 100;
msgLabel.text = tweet.msg;
msgLabel.setStyle("fontSize",12);
msgLabel.setStyle("color",msgColor);
msgLabel.editable = false;
msgLabel.setStyle("lineBreak", "toFit");
vg.addElement(hgM);
//Date
var hgD:HGroup = new HGroup();
var dSpacer:Spacer = new Spacer();
dSpacer.width = 10;
hgD.addElement(dSpacer);
var dateLabel:Label = new Label();
dateLabel.text = tweet.postingDate.date;
dateLabel.setStyle("fontSize",10);
dateLabel.setStyle("color",dateColor);
hgD.addElement(dateLabel);
vg.addElement(hgD);
var sp1:Spacer = new Spacer();
sp1.height = 10;
vg.addElement(sp1);
var hr:HRule = new HRule();
hr.percentWidth = 90;
hr.x = 20;
vg.addElement(hr);
return vg;
}
First off, why are you using Actionscript when your application is clearly Flex? You could reduce that mess of code by 2/3. Also, last I checked they all resize to their content unless you specify their dimensions. Either way, here's an example which works great:
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx">
<fx:Script>
<![CDATA[
[Bindable] private var someText:String = "Enter long text here.";
]]>
</fx:Script>
<s:RichEditableText selectable="true" editable="false" text="{someText}" multiline="true" width="100%" />
</s:Application>

Resources